A caching layer for seaport that lets you run nicely even if the seaport server dies.
This library takes a connected seaport object and caches all the results so that if the connection with seaport is lost, we can still run using the cached data.
Also adds some nice functions to automatically select a host based on random or round-robin principles.
Run the seaport service and register a server as normal.
On the client use like this:
var request = ;var seaport = ;var spcache = ;var ports = seaport;var cache = spcache;;
var seaportcache = require('seaport-cache');
Takes the ports object returned from
seaport.connect and returns the cache object which you can query directly.
Request an array of host/port objects through
cb(services) that fulfill
If there are no services that match the callback will be queued until some fulfilling
role gets allocated.
get, but returns just the first host/port object instead of the whole array, equive to using
services in the callback.
get but returns a random host/port object from the array.
get but returns the first entry from the array on the first call, the second entry from the array on the second call, etc.
The round robin is based on the exact role string used, so different role queries get different sequences even if they match the name sequence of servers.