A node module for smart subprocess handling with support for promises and streamlined subprocess communication.
Go to file
Phil Kunz 7c7f2f8b90 Merge branch 'master' into 'master'
start implementation

See merge request !1
2017-01-19 19:17:21 +00:00
dist switch to native ipc to scale down on dependencies 2016-09-28 23:46:28 +02:00
test start implementation 2017-01-18 16:54:39 +01:00
ts start implementation 2017-01-18 16:54:39 +01:00
.gitignore initial 2016-09-28 13:01:36 +02:00
.gitlab-ci.yml ad gitlab.yml 2016-09-28 20:22:05 +02:00
npmextra.json switch to native ipc to scale down on dependencies 2016-09-28 23:46:28 +02:00
package.json start implementation 2017-01-18 16:54:39 +01:00
README.md improve README 2016-09-28 14:23:47 +02:00
tslint.json initial 2016-09-28 13:01:36 +02:00

smartipc

smart subprocess handling

Availabililty

npm git git docs

Status for master

build status coverage report Dependency Status bitHound Dependencies bitHound Code TypeScript node JavaScript Style Guide

The purpose

smartipc makes it easy to spawn tasks into subprocesses without loosing control over what those processes do. You can transparently call functions and expect returned data using promises.

Usage

Server:

import {Ipcserver} from 'smartipc'
import * as q from 'q'

let myIpcserver = new Ipcserver({
    appspace: 'mymodule'
})

// The subprocess js file cannot have any cli arguments
// since this mechanism is used by IpcServer to setup the connection
myIpcServer.spawnProcess('./myFile','mySubProcessNameAlias') // nameAlias identifies the subprocess and will prefix any logs from child Process

let someData = {
    key1: 'value1',
    key2: 'value2'
}

myIpcServer.call('mySubProcessNameAlias','myAwesomeFunction',someData).then(someAnswerData => {
    console.log(someAnswerData.key1)
})

Client:

import { Ipcclient } from './smartipc'
import * as q from 'q'

let localIpc = new Ipcclient() // gets its connection information automatically using CLI args internally

let myAwesomeFunction = (dataArg) => {
    let done = plugins.q.defer()
    console.log('awesome') // this will log transparently in the same console stream as the host process
    let someAnswerData = {key1: 'this is an answer'}
    done.resolve(someAnswerData)
    return done.promise
}

localIpc.register([myAwesomeFunction])

npm