node-cluster-hub
A layer for communcation between master and worker processes
Installation
npm install cluster-hub
Getting started
var Hub = ;var cluster = ;var hub = ; if clusterisMaster // in master process hub; var worker = cluster; else //in worker process hub;
Simple message sending
hub; //works from workers and masterhub; // works from masterhub;
Examples:
- https://github.com/sirian/node-cluster-hub/blob/master/examples/index.js
- https://github.com/sirian/node-cluster-hub/blob/master/examples/broadcast.js
Requests between master and workers (with callback)
Same as simple messaging, but you can provide a callback
hub; //works from workers and masterhub; // works from master
Example in "Getting Started" section, and here: https://github.com/sirian/node-cluster-hub/blob/master/examples/requests.js
Exclusive Locks
This module provide a way to get global exclusive lock between all processes (master and workers). If worker process dies while holding locked section - lock will be released automatically.
// this method available in master and in workershub
Example: https://github.com/sirian/node-cluster-hub/blob/master/examples/locks.js
Examples
More examples here: https://github.com/sirian/node-cluster-hub/tree/master/examples