Rebus allows sharing JSON objects between multiple nodejs processes, running on the same host. It uses file system to share state. Objects published via rebus remain persistent. Rebus supports change notifications (subscriptions) on any sub-tree of the shared state. Therefore, it can be used as light-weight pubsub system in scope of one host.
Applications are responsible to devide name space and to avoid publishing overlapping objects. E.g. if one applicaiton would publish object x.y.z and another application will publish oject x.y, the result will be unpredictable. It is OK for one application to publish object x.y and to other application to publish object x.z, as those 2 are not overlapping.
The following demonstrates usage of rebus.
var rebus = ;// Create rebus instance, specifying the directory where shared state// is maintained. Application communicating on this bus instantiate// rebus in the same directory.var bus =;
Rebus can be instantiated and used synchronously:
var rebus = ;var bus = ;// Read.console;// Write.bus;// bus.value.x is not necessary the one assigned as not used in publish// completion. However, it is still can be used and it includes some value// that was in x, before or after assignment.console;// Cleanupbus;
Note: using rebus value or function before instantiation completion works, exception may be thrown if other process manipulates shared state concurently. However, if garanteed that nobody writes into the same directory, rebus will work correctly and show the right value of the shared object. The best practice would be to start using rebus upon instantiation completion.