Solidipes
A partially connected mesh network with messaging and discovery.
Motive
There are many solutions for service discovery for Node. Solidipes provides node discovery and low latency message routing to serve as a foundation for distributed service discovery.
Test
Run any of the following:
$ mocha$ npm test$ make test
Note: remember to npm install
!
Install
$ npm install solidipes
API
Solidipes exports a Network constructor.
var Network = ; var id = ; var net = // auto-generated if not included id: id // listen on port 3000, defaults to a random open port port: 3000;
Network([options])
Create a new network instance.
var net = // defaults to an auto-generated 32-digit hex string, provide this if useful id: 'a94312d853e585bc41c1ff990f120b1b' // the interval on which to garbage collect the seen messages structure cleanup: 10000 // default // the host to bind the server to, finds an external address if not provided host: 'localhost' // the port to listen on, defaults to a random open port port: 3000 // number of neighbor nodes to keep in contact with locals: 8 // default;
info()
Returns the formatted transport connection info.
seed(info)
Seed the network with transport info, which can be retrieved back calling network.info()
.
// get the transport infovar info = network; // broadcast the info to another process somehow // seed the network with the remote transport infonet;
size()
Gets the size of the network in number of nodes.
netsize; // => 0
to(target, [options])
Specifies the recipient and options of an event emit. If target is null, designates a global broadcast.
// broadcast to everybody! (realistically just do .emit)net; // unicast to the specified nodenet; // multicast to two nodesnet; // direct-unicast to the specified node (must be a neighbor node)net; // the redundant option specifies how much the message should be replicated// higher numbers mean the message has a high likelyhood of reaching its destination// lower numbers mean fewer wasted packetsnet;
emit(event, [args...], [callback])
Broadcast an event to all nodes in the network.
net;
Events
add(node)
Emitted when a node is added to the network, either manually or through node discovery.
net;
remove(node)
Emitted when a node is removed from the network.
net;
garbage(count)
Emitted as message records are cleaned up on the provided interval.
net;
error(err)
General error event, usually emitted during parse. Make sure you also add an error listener on the transport.
net;
unknown(packet)
Emitted when solidipes receives a valid but unknown packet.
net;
Target#emit(event, [args...], [callback])
Emit an event to the represented Target (returned by Network#to
).
net;
Roadmap
Okay. Many flaws fixed, still no roadmap.
License
The MIT License (MIT)
Copyright © 2014 GlobeSherpa
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.