node package manager
Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org ยป



Simple Inter-Node (cluster) Communication, powerd by Redis.




  • Real-time messaging between (server/cluster) nodes via Redis.
  • Simple API - easy to use!
  • Supports string, JSON object and binary.
  • Messaging types:
    • Unicat
    • Multicast
    • Broadcast
  • Transfer Modes:
    • Inband: Deliver message inband (sending user data over redis pub-sub)
    • Outband: Deliver message outband (good for unicasting large data)
    • Auto: (not implemented yet)
  • Support of multiple 'channels' - a logical communication domain between nodes.


Create my sinc object

var sinc = require('sinc');
var mySinc = sinc.create('sinc for my app');

Create a channel

var myCh = mySinc.createChannel('my channel');

Create a node, then send & receive messages

var n01 = myCh.createNode('node 01');
n01.on('message', function(node, msg, from) {
	// Handle received message
n01.send('Hello, World!', 'node 02');



Class: Sinc (extends events.EventEmitter)

Class: Channel (extends events.EventEmitter)

Class: Node (extends events.EventEmitter)


### create(sincId, [redisPort], [redisHost]) Creates a Sinc object.
  • sincId {string} - Sinc object ID. Typically an unique string that represents your application.
  • redisPort {number} - Redis port number. Defaults to 6379.
  • redisHost {string} - Redis host name. Defaults to 'localhost'
### setLogger(logger) Set custom logger. The logger object must have the following method:
  • error()
  • warn()
  • info()
  • debug()

By default, sinc module uses 'fuzelog'.

Mode {object}

Transfer mode.

  • Inband: 0 - Default. Data is sent using redis publish.
  • Outband: 1 - Data is stored in redis first then notify receiver of the data using pubsub.
  • Auto: 2 - Let sinc decide which mode should use. (not implemented yet)

Class: Sinc

### createChannel(chId) Creates a channel object.
  • chId {string} - A unique channel ID within the sinc ID.
### getNumChannels() Gets the number of channels currently active. ### Event: 'ready' Notified when the sinc object become ready.

CALLBACK: function( ) { }

### Event: 'error' CALLBACK: function(err) { }
  • err {string} - A text that describes the error.

Class: Channel

### createNode(nodeId) Creates a node (a communication endpoint) object.
  • nodeId {string} - A unique node ID within the channel ID.
### close() Close this channel. ### getNumNodes() Returns the number of nodes on this channel. ### Event: 'ready' Notified when the channel has become ready to use.

CALLBACK: function( ) { }

### Event: 'close' Notified when this channel has been closed.

CALLBACK: function( ) { }

Class: Node

### send(msg, to, [options]) Sends a message to a specified destiation, or a set of destinations.
  • msg {string|object|Buffer} - A message to send. When the type is 'object', it assumes the object is a JSON object.
  • to {string|array} - Destination node(s).
  • options {object}:
    • mode {number} - Transfer mode. Mode.Inband by default.
### broadcast(msg, [options]) Broadcasts a message.
  • msg {string|object|Buffer} - A message to send. When the type is 'object', it assumes the object is a JSON object.
  • options {object}:
    • mode {number} - Transfer mode. Mode.Inband by default.
    • loopback {boolean} - Whether to loopback the broadcasted message.
### close() Closes this node. ### Event: 'message' Notified when a message has been received on this node.

CALLBACK: function(node, msg, from) { }