Hi,
I have build a small "RPC IPC" library over the new core module
'cluster'. It allows me to write code such:
//server.js
var ipc = require('ipc-message');
ipc.add(worker); //or workers if it is an array
//call one random process which have registered 'add'
ipc.call('add', 2, 3, function(result) {
console.log("2 + 3 = " + result);
});
//somewhere else
ipc.register('add', function(a, b, next) {
next(a+b); //any arguments will be forwarded back
});
Good to know:
- If there exist a local version (register and call in same process),
will it be called first.
- The library will randomly select one process which has registered
the method, so multiply calls to 'add' in the example will be
automatically distributed over all processes which has it.
- If any process goes down which does "some task" and another process
implements it, will it be automatically redirected to that process.
- All messages will be assembled into one larger message and
transported every "process.nextTick", so doing multiply ipc.call(...)
in a row will only require a single IPC call.
- Timeout values can very easily be made, however I don´t know what is
the best way to do this from the user side.
- In the current form is it only a "proof of concept", so minimal
testing have been done, however the library is lightweight so it
should be easy to fix.
It has no dependencies over core node.js (cluster). My questions is as
follow:
- Will node.js implement anything like this in the future?
- Does it exist any lightweight library yet which offer something
similar like above, which works on node.js version 6.0 and above?
- I want to improve this "proof of concept" library to a fully
productions ready library and release it to the public, but I feel I
need help on that side. Specially I don´t really know what is the best
strategy to send Error messages to the handler (Method not Found),
first parameter, a custom error callback? Any tips?
If anyone want to check out the code can I upload it, but let me know
if anyone is interested first.
Thanks in advance!
--
Job Board: http://jobs.nodejs.org/
Posting guidelines:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en