$ cnpm install sombrero-node
Node of a Sombrero cluster. Uses Skiff (A Raft implementation) underneath.
$ npm install sombrero-node --save
var Node = require('sombrero-node');
var url = 'tcp+msgpack://localhost:8000';
var port = 7000;
var options = {
skiff: {
dbPath: '/path/to/my/leveldb/dir'
},
port: port
};
var node = Node(url, options);
skiff
: all the options supported by skiffport
: the TCP port for exposing the RPC server. Defaults to 5201
.transport
: a transport module provider. Defaults to this.gossip
: an object with the following attributes:
port
: gossip port. defaults to 8217A Sombrero node implements the level-up API.
You can also extend the client with level-* plugins, including sublevel.
Joins a node given its URL. Options should contain the hostname and port of the node Sombrero RPC server.
Example:
var options = {
hostname: 'localhost',
port: 8071
};
node.join('tcp+msgpack://hostname:8000', options, function(err) {
if (err) throw err;
console.log('joined');
});
Leaves a node given its URL.
Closes the server and the skiff node.
A Sombrero node emits the same events as a Skiff node.
To boot a cluster, start a node and wait for it to become a leader. Then, create each additional node in the standby
mode (options.skiff.standby: true
) and do leader.join(nodeURL)
.
See this test for an actual implementation.
ISC
Copyright 2014 - 2017 © taobao.org |