Skip to content

litehelpers/deepstream-cluster-free

 
 

Repository files navigation

Deepstream.io Cluster

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

Please see https://deepstreamhub.com/enterprise/ for commercially supported enterprise clustering from deepstreamHub GmbH.

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. WARNING: EXTREMELY RESTRICTIVE AGPL LICENSE

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%