Community supported clustering for deepstream.io. Based on Nanomsg.
Please see https://deepstreamhub.com/enterprise/ for commercially supported enterprise clustering from deepstreamHub GmbH.
yarn install deepstream.io-cluster
The deepstream.io-cluster
module extends the base deepstream.io
.
Peers bootstrap off of each other.
const Deepstream = require('deepstream.io-cluster');
const server = new Deepstream();
const Deepstream = require('deepstream.io-cluster');
const server = new Deepstream({
cluster: {
peerAddresses: [
{
host: '192.168.1.1'
}
]
},
});
const Deepstream = require('deepstream.io-cluster');
const server = new Deepstream();
server.addPeer({host: '192.168.1.1'});
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
}
]
},
});
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,
// },
// ]