Simple Inter-Node Communication backed by redis.


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.
var sinc = require('sinc');
var mySinc = sinc.create('sinc for my app');
var myCh = mySinc.createChannel('my channel');
var n01 = myCh.createNode('node 01');
n01.on('message', function(node, msg, from) {
    // Handle received message
n01.send('Hello, World!', 'node 02');

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'

Set custom logger. The logger object must have the following method:

  • error()
  • warn()
  • info()
  • debug()

By default, sinc module uses 'fuzelog'.

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)

Creates a channel object.

  • chId {string} - A unique channel ID within the sinc ID.

Gets the number of channels currently active.

Notified when the sinc object become ready.

CALLBACK: function( ) { }

CALLBACK: function(err) { }

  • err {string} - A text that describes the error.

Creates a node (a communication endpoint) object.

  • nodeId {string} - A unique node ID within the channel ID.

Close this channel.

Returns the number of nodes on this channel.

Notified when the channel has become ready to use.

CALLBACK: function( ) { }

Notified when this channel has been closed.

CALLBACK: function( ) { }

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.

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.

Closes this node.

Notified when a message has been received on this node.

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