start implementation

This commit is contained in:
Philipp Kunz 2017-01-18 16:54:39 +01:00
parent 5ce83601b4
commit f0f2761949
8 changed files with 41 additions and 105 deletions

View File

@ -18,14 +18,15 @@
},
"homepage": "https://gitlab.com/pushrocks/smartipc#README",
"dependencies": {
"@types/lodash": "^4.14.36",
"beautylog": "^5.0.23",
"lodash": "^4.16.2",
"@types/lodash": "^4.14.50",
"beautylog": "^6.0.0",
"lodash": "^4.17.4",
"threads": "^0.7.2",
"typings-global": "^1.0.14"
},
"devDependencies": {
"@types/should": "^8.1.30",
"should": "^11.1.0",
"should": "^11.1.2",
"typings-test": "^1.0.3"
}
}

0
test/child.d.ts vendored Normal file
View File

4
test/child.js Normal file
View File

@ -0,0 +1,4 @@
"use strict";
const smartipc = require("../dist/index");
let localChild = new smartipc.IpcChild({});
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2hpbGQuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyJjaGlsZC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsMENBQXlDO0FBRXpDLElBQUksVUFBVSxHQUFHLElBQUksUUFBUSxDQUFDLFFBQVEsQ0FBQyxFQUFFLENBQUMsQ0FBQSJ9

View File

@ -1,22 +0,0 @@
import * as plugins from './smartipc.plugins'
import { IpcTarget } from './smartipc.classes.ipctarget'
export interface IpcChildConstructorOptions {
}
let defaultOptions: IpcChildConstructorOptions = {
}
/**
* class Ipcclient represents the child process
*/
export class IpcChild extends IpcTarget {
constructor(optionsArg: IpcChildConstructorOptions) {
super({alias: 'child'})
}
call(ipctarget,targetFunction,dataArg) {
}
}

View File

@ -1,48 +0,0 @@
import * as plugins from './smartipc.plugins'
import { IpcTarget } from './smartipc.classes.ipctarget'
export interface IIpcServeOptions {
}
let defaultOptions: IIpcServeOptions = {
}
export interface IIpcChildProcess {
alias: string
filePath: string
childProcess: plugins.childProcess.ChildProcess
}
/**
* class Ipcserve is represents the master process for any chil processes
*/
export class IpcMaster extends IpcTarget {
ipcOptions: IIpcServeOptions
childProcessArray: IIpcChildProcess[]
constructor(ipcOptionsArg: IIpcServeOptions) {
super({alias: 'master'})
this.ipcOptions = plugins.lodash.merge({},defaultOptions,ipcOptionsArg)
}
/**
* spawns a child process
*/
spawnProcess(filePath: string, alias: string) {
let childProcess = plugins.childProcess.fork('ls', ['-lh', '/usr'])
childProcess.stdout.on('data', (data) => {
console.log(`stdout: ${data}`)
})
childProcess.stderr.on('data', (data) => {
console.log(`stderr: ${data}`)
})
childProcess.on('close', (code) => {
console.log(`child process exited with code ${code}`)
})
}
}

View File

@ -1,27 +0,0 @@
import * as plugins from './smartipc.plugins'
export interface ITargetConstructorOptions {
alias: string
}
/**
*
*/
export class IpcTarget {
alias: string
private funcArray: any[]
constructor(optionsArg: ITargetConstructorOptions) {
this.alias = optionsArg.alias
}
/**
* registers a function
*/
register(funcArrayArg: any[]) {
for (let funcItem of funcArrayArg){
this.funcArray.push(funcItem)
}
}
}

View File

@ -0,0 +1,32 @@
import 'typings-global'
let threads = require('threads')
export interface IThreadFunction {
(input, done): void
}
export class Thread {
thread
constructor(functionArg: IThreadFunction) {
this.thread = threads.spawn(functionArg)
this.thread.on('error', function() {
})
this.thread.on('exit' function() {
})
this.thread.on('message')
}
/**
* sends a message to the spawned process
*/
send(message) {
this.thread.send(message)
}
/**
* sends a message to
*/
}

View File

@ -1,4 +0,0 @@
import 'typings-global'
export import beautylog = require('beautylog')
export import lodash = require('lodash')
export import childProcess = require('child_process')