add README
This commit is contained in:
		
							
								
								
									
										66
									
								
								README.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										66
									
								
								README.md
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,66 @@
 | 
			
		||||
# smartipc
 | 
			
		||||
smart subprocess handling
 | 
			
		||||
 | 
			
		||||
## Availabililty
 | 
			
		||||
[](https://www.npmjs.com/package/smartipc)
 | 
			
		||||
[](https://gitlab.com/pushrocks/smartipc)
 | 
			
		||||
[](https://github.com/pushrocks/smartipc)
 | 
			
		||||
[](https://pushrocks.gitlab.io/smartipc/)
 | 
			
		||||
 | 
			
		||||
## Status for master
 | 
			
		||||
[](https://gitlab.com/pushrocks/smartipc/commits/master)
 | 
			
		||||
[](https://gitlab.com/pushrocks/smartipc/commits/master)
 | 
			
		||||
[](https://david-dm.org/pushrocks/smartipc)
 | 
			
		||||
[](https://www.bithound.io/github/pushrocks/smartipc/master/dependencies/npm)
 | 
			
		||||
[](https://www.bithound.io/github/pushrocks/smartipc)
 | 
			
		||||
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
 | 
			
		||||
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
 | 
			
		||||
[](http://standardjs.com/)
 | 
			
		||||
 | 
			
		||||
## 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:
 | 
			
		||||
```typescript
 | 
			
		||||
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])
 | 
			
		||||
```
 | 
			
		||||
		Reference in New Issue
	
	Block a user