Skip to content

wehriam/deepstream.io-cluster

Repository files navigation

Deepstream.io Cluster

Community supported clustering for deepstream.io. Based on Nanomsg.

CircleCI npm version

Usage

yarn install deepstream.io-cluster

The deepstream.io-cluster module extends the base deepstream.io.

Peers bootstrap off of each other.

Server A, 192.168.1.1

const Deepstream = require('deepstream.io-cluster');

const server = new Deepstream();

Server B, 192.168.1.2

const Deepstream = require('deepstream.io-cluster');

const server = new Deepstream({
  cluster: {
    peerAddresses: [
      {
        host: '192.168.1.1'
      }
    ]
  },
});

Server C, 192.168.1.3

const Deepstream = require('deepstream.io-cluster');

const server = new Deepstream();

server.addPeer({host: '192.168.1.1'});

Options

const Deepstream = require('deepstream.io-cluster');

const server = new Deepstream({
  cluster: {
    bindAddress: {
      host: '127.0.0.1', // Optional, default '127.0.0.1'
      pubsubPort: 6021, // Optional, default 6021
      pipelinePort: 6022, // Optional, default 6022
    },
    peerAddresses: [
      {
        host: '127.0.0.1', // Required
        pubsubPort: 6021, // Optional, default 6021
        pipelinePort: 6022, // Optional, default 6022
      }
    ]
  },
});

Methods

server.addPeer({
  host: '192.168.1.2', // Required
  pubsubPort: 6021, // Optional, default 6021
  pipelinePort: 6022, // Optional, default 6022
});
// Returns a Promise.

server.removePeer({
  host: '192.168.1.2', // Required
  pubsubPort: 6021, // Optional, default 6021
  pipelinePort: 6022, // Optional, default 6022
});

Automatic peer discovery with node-discover

const options = {}; // See options at https://github.com/wankdanker/node-discover#constructor

// Returns a Promise.
server.startPeerDiscovery(options);

// later
server.stopPeerDiscovery();
server.getPeers();

// Returns:
//
// [
//   {
//     serverName: "server-2",
//     host: '192.168.1.2',
//     pubsubPort: 6021,
//     pipelinePort: 6022,
//   },
//   {
//     serverName: "server-3",
//     host: '192.168.1.3',
//     pubsubPort: 6021,
//     pipelinePort: 6022,
//   },
// ]

About

Community supported clustering for Deepstream.io.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published