node-ipc-call
Non-blocking cross-process method call based on IPC for Node.js.
$ npm install --save node-ipc-call
Usage
const Caller = ; const invoker = Caller; await invoker;await invoker; // 3 invoker;
// ./foo.jsconst Callee = ; const callee = ; // async methodcallee; // sync methodcallee; callee;
API
Class: Caller
Added in: v0.0.1
Caller.fork(modulePath, args, options)
Added in: v0.0.1
Caller.fork()
take the same parameters of child_process.fork().
Returns .
Class: Invoker
Added in: v0.0.1
Returned by Caller.fork()
, you should make remote function calls via Invoker
.
invoker.invoke(name, args[, options])
Added in: v0.0.1
name
{String} The remote function name.args
{Array} Arguments passed to the remote function.options
{Object}timeout
{Number} In milliseconds. Default: 3000.
Returns <Promise>
.
invoker.destroy()
Added in: v0.0.1
Closes the IPC channel to child process, and rejects all pending calls.
Class: Callee
Added in: v0.0.1
callee.register(arg)
Added in: v0.0.1
arg
{Function|Object|Array} The functions or an array of functions exposed to remote call.
Each function to be registered should have an unique name, register the same function multiple times is ok.
callee;callee;callee;callee; // Error
callee.listen()
Added in: v0.0.1
Starts to listen for method calls from parent process.
callee.destroy()
Added in: v0.0.1
Stops listening method calls from parent process.
License
MIT