node package manager
Easy collaboration. Discover, share, and reuse code in your team. Create a free org »

skiff-client

skiff-client

Build Status Dependency Status

Client for Skiff (Node.js implementation of the Raft algorithm).

  • Persistence: LevelDB
  • Protocol: Msgpack over TCP

Install

$ npm install skiff-client

Create

var SkiffClient = require('skiff-client');
var node = SkiffClient('tcp+msgpack://localhost:8081');

or, with options:

var options {
  // ... 
};
 
var node = SkiffClient('tcp+msgpack://localhost:8081', options);

Options

  • autoListen: start listening on bootup. defaults to true.
  • transport: transport type. Supported values:
    • tcp-msgpack: Msgpack over TCP (default)
    • tcp-nlsjson: New-line separated JSON over TCP
  • dbPath: database path
  • waitLeaderTimeout: the time to wait to become a leader. defaults to 3000 (ms).

Use

A skiff client object implements the level-up API.

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

Other than that, you can:

.listen(cb)

Listen for nodes connecting to us.

.join(url, cb)

Joins a node given its URL.

.leave(url, cb)

Leaves a node given its URL.

License

ISC