New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

federation

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

federation

Federated Node.js Actor Network

  • 0.0.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
19
decreased by-44.12%
Maintainers
1
Weekly downloads
 
Created
Source

Introduction

Federation is an actor system for Node.js inspired by Erlang and Akka.

Install

$ npm install federation

Usage

Federation nodes can send and receive messages to each other.

var router = require('federation').router;

var node1  = router.createNode('node1');
var node2  = router.createNode('node2');

Send a Message

Every node exists at a URL, and can be messaged at that URL. For nodes on the same host, the host and protocol can be omitted.

var message = "Hello World";
var address = "/node2";
node1.tell(address,message);

Federation can also send messages across the network to remote nodes:

var address = "axon://192.168.0.12/node2";
var message = "Hello from 192.168.0.9";
node1.tell(address,message);

Receive Messages

Each node can be assigned a single receive function, which will be called whenever the node receives a message.

node1.receive = function(message){
  // handle message
}

Request/Reply Pattern

Nodes can reply contextually using the ask method.

node1
.ask('/node2','How old are you?')
.receive(function(msg){
  console.log('Got Reply',msg);
});

The request/reply pattern uses anonymous nodes, i.e. one-time actors. Anonymous nodes have a default timeout of 5000, after which an error will be triggered. You can respond to the error with:

node1.ask('/nod2','How old are you?')
.receive(function(msg){
  // handle reply
})
.error(function(err){
  // handle error
})

FAQs

Package last updated on 31 Jan 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc