0.2.13 • Published 9 years ago

node-fork-rpc v0.2.13

Weekly downloads
5
License
BSD
Repository
github
Last release
9 years ago

node-fork-rpc

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.

Install: npm install node-fork-rpc

Usage from Parent Process:

var nodeFork = require('node-fork-rpc');

var passedApi = require('passedApi');

nodeFork.run("full path to passedApi", function(childProcessRef) {
	childProcessRef.one("One Tada", function(info) {
		console.log("One Got back:", info);
	});
	childProcessRef.two("Two Tada", function(info){
		console.log("Two got back:", info);
	});
});

Usage for child process:

var passedApi = require("passedApi"), nodeFork = require("node-fork-rpc");

nodeFork.register(passedApi);

Passed Api:

module.exports = {
	getApi: function(register, isChild){
		register({
			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");
			}
		})
	}
}

TODO:

  1. Add some way to monitor/restart child process
0.2.13

9 years ago

0.2.12

10 years ago

0.2.11

10 years ago

0.2.10

10 years ago

0.2.9

10 years ago

0.2.8

10 years ago

0.2.7

10 years ago

0.2.6

10 years ago

0.2.5

10 years ago

0.2.4

10 years ago

0.2.3

10 years ago

0.2.2

10 years ago

0.2.1

10 years ago

0.2.0

10 years ago

0.1.0

10 years ago