Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 1,000,000+ packages pre-installed, including sombrero-node with all npm packages installed. Try it out:

var sombreroNode = require("sombrero-node")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

sombrero-node v0.8.8

Sombrero Cluster Node

Sombrero Node

Build Status Dependency Status

Node of a Sombrero cluster. Uses Skiff (A Raft implementation) underneath.

  • As a leader, creates an independent RPC server for servicing requests from followers.
  • As a follower, forwards the write requests to the leader.
  • As a follower, makes sure that the leader writes to the issuing follower before returning.
  • Because of this last point, it implements a read-your-writes on a follower.


$ 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 skiff
  • port: 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 8217


A Sombrero node implements the level-up API.

You can also extend the client with level-* plugins, including sublevel.

.join(url, options, cb)

Joins a node given its URL. Options should contain the hostname and port of the node Sombrero RPC server.


var options = {
  hostname: 'localhost',
  port: 8071

node.join('tcp+msgpack://hostname:8000', options, function(err) {
  if (err) throw err;

.leave(url, cb)

Leaves a node given its URL.


Closes the server and the skiff node.


A Sombrero node emits the same events as a Skiff node.

Setting up a cluster

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.



RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free