node package manager
It’s your turn. Help us improve JavaScript. Take the 2017 JavaScript Ecosystem Survey »



Replicate a seaport service registry for fast local in-memory access or redundancy.

build status


var seaport = require('seaport');
var pier = require('pier');
var server = seaport.createServer().listen(7890);
var cache = pier().tie(7890);
setInterval(function () {
}, 1000);

first start the server/cache program:

$ node example/cache.js 
[ { host: '', port: 9999, role: 'beep', version: '0.0.0' } ]
[ { host: '', port: 9999, role: 'beep', version: '0.0.0' } ]

meanwhile, register and unregister some services:

$ node
> var ports = require('seaport').connect(7890)
> ports.assume('beep', 9999)
>{ role : 'beep', port : 9999 })


var pier = require('pier')

var p = pier(query)

Create a new seaport server p with an optional semver query to filter the local cache by.

p.tie(ports), pier.tie(...)

Tie a remote seaport server given either the handle itself or the parameters to pass to seaport.connect(...).

Returns the local seaport caching server p.


In addition to all the usual events that seaport servers emit ('assume', 'allocate', 'free'), these extra events are emitted:

p.on('ready', function (records) { /* ... */ })

Emitted when the initial recordset is ready. When the remote server is first bound, a query() is issued against it to get the initial recordset.

p.on('update', function (records) { /* ... */ })

Emitted when the recordset changes. If query was specified, the records parameter will be filtered, otherwise records is the entire recordset.


With npm do:

npm install pier