RPC Wrapper for NodeJS fork messages.
This simple wrapper allows you to call methods in your child process as though they were local to your parent process.
Limitations: Parameters must be serializable! No functions, sockets or any other type of system resource.
Features: The last parameter you send will be checked to see if it is a function. If it is, that function will be made available as a call back to your child process.
Usage from Parent Process:
var nodeFork = require('../index');
var passedApi = require('./passedApi');
var client = nodeFork.run(passedApi, 'examples/apiService');
client.one("One Tada", function(info) { console.log("One Got back:", info); }); client.two("Two Tada", function(info){ console.log("Two got back:", info); });
Usage for child process:
var passedApi = require("./passedApi"), nodeForkRpc = require("../index.js");
nodeForkRpc.register(passedApi);
Passed Api:
module.exports = { one: function(doOne, callback) { console.log("One Boo", arguments); callback("One boo calling back"); }, two: function(doTwo, callback) { console.log("Two Boo", arguments); callback("Two boo calling back"); } };