Socket
Book a DemoInstallSign in
Socket

mortable

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mortable

In memory eventual consistant distributed data structure

latest
Source
npmnpm
Version
2.0.0
Version published
Maintainers
1
Created
Source

mortable

In memory eventual consistant distributed data structure

npm install mortable

build status

Mortable is for sharing data that is only valid as long as your process is alive and small enough to fit in memory (think hostnames+ports for a distributed service registry)

Data will be replicated to other nodes using protobuf messages and the scuttlebutt protocol

Usage

var mortable = require('mortable')
var table = mortable()

table.push('hello', 'world')     // push world to the hello data set
console.log(table.list('hello')) // prints ['world']

var table2 = mortable()

table2.push('hello', 'mundo')

var stream = table.createStream()
stream.pipe(table2).pipe(stream) // start replicating between the two tables

setImmediate(function() {
  console.log(table2.list('hello')) // will print ['world', 'mundo']
})

To replicate the data structure to other nodes use .createStream() and pipe it to a network stream

var stream = table.createStream()

// will start replicating this data structure to other nodes
streamToAnotherPeer.pipe(stream).pipe(streamToAnotherPeer)

If you want to destoy your table call table.destroy() which will remove all local values from the replicas. If you do not call destroy and exits your process the values will be removed after a timeout (~10s)

Credits

Credits to dominictarr for making the excellent scuttlebutt module that inspired this

License

MIT

FAQs

Package last updated on 08 Aug 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts