Giter Club home page Giter Club logo

sombrero-node's Introduction

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.

Install

$ npm install sombrero-node --save

Require

var Node = require('sombrero-node');

Create

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);

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

Use

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.

Example:

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

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

.leave(url, cb)

Leaves a node given its URL.

.close(cb)

Closes the server and the skiff node.

Events

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.

License

ISC

sombrero-node's People

Contributors

pgte avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.