diff --git a/README.md b/README.md
index 22ff461..e47406d 100644
--- a/README.md
+++ b/README.md
@@ -94,7 +94,7 @@ All communications between the master and a child must be started by the child.
To do so you can use the second parameter passed in all functions provided to the taskMap `toggleIPC` which is prototyped as follow :
`toggleIPC(messageBroker: function, initalize: function): Promise`
-- `messageBroker` is prototyped as `messageBroker(msg: Any, closeIPC: function)`
+- `messageBroker` is prototyped as `messageBroker(msg: Any)`
- `initialize` is prototyped as `initialize(sendMessageToMaster: function)`
because `toggleIPC` returns a promise you must return it (recursively), otherwise the job will be considered done, and the worker Idle.
@@ -210,11 +210,10 @@ in such case your overall system should be **slowed down** because some of the p
```
function ipcPingTest(job, toggleIPC) {
return toggleIPC(
- (msg, closeIPC) => {
+ (msg) => {
console.log(msg)
- const result = 'result you eventually want to pass to the master'
- closeIPC(result)
- }, (sendMessageToMaster) => sendMessageToMaster({ status: 4, data: 'ping' })
+ return 'result you eventually want to pass to the master'
+ }, (smtm) => smtm({ status: 4, data: 'ping' })
)
}
@@ -235,17 +234,13 @@ const cluster = new Cluster(taskMap, { messageBroker })
```
function ipcPingTest(job, toggleIPC) {
return toggleIPC(
- (msg, closeIPC) => {
+ (msg) => {
console.log(msg)
- closeIPC(
- toggleIPC(
- (msg, closeIPC) => {
- console.log(msg)
- closeIPC()
- }, (sendMessageToMaster) => sendMessageToMaster({ status: 4, data: 'ping' })
+ return toggleIPC(
+ (msg) => console.log(msg),
+ (smtm) => smtm({ status: 4, data: 'ping' })
)
- )
- }, (sendMessageToMaster) => sendMessageToMaster({ status: 4, data: 'ping' }))
+ }, (smtm) => smtm({ status: 4, data: 'ping' }))
}
const taskMap = {
diff --git a/package.js b/package.js
index 41d8fa0..88de9ca 100644
--- a/package.js
+++ b/package.js
@@ -1,6 +1,6 @@
Package.describe({
name: 'nschwarz:cluster',
- version: '2.0.1',
+ version: '2.1.0',
summary: 'native nodejs clusterization for meteor server',
git: 'https://github.com/nathanschwarz/meteor-cluster.git',
documentation: 'README.md'
diff --git a/src/Worker/ChildWorker.js b/src/Worker/ChildWorker.js
index de867c6..f8fb2a6 100644
--- a/src/Worker/ChildWorker.js
+++ b/src/Worker/ChildWorker.js
@@ -13,7 +13,7 @@ class ChildWorker {
static toggleIPC(messageBroker, initialize) {
return new Promise((resolve, reject) => {
process.removeAllListeners('message')
- process.on('message', (msg) => messageBroker(msg, resolve))
+ process.on('message', (msg) => resolve(messageBroker(msg)))
initialize(ChildWorker.sendMsg)
}).catch(e => {
throw new Error(e)
@@ -50,4 +50,4 @@ class ChildWorker {
}
}
-export default ChildWorker
\ No newline at end of file
+export default ChildWorker
diff --git a/src/tests/ipcTests.js b/src/tests/ipcTests.js
index f01faa3..819a5f0 100644
--- a/src/tests/ipcTests.js
+++ b/src/tests/ipcTests.js
@@ -1,23 +1,16 @@
function ipcSinglePingTest(job, toggleIPC) {
return toggleIPC(
- (msg, closeIPC) => {
- console.log(`\n\n${msg}\n\n`)
- closeIPC()
- }, (smtm) => smtm({ status: 4, data: 'ping' })
+ (msg) => console.log(`\n\n${msg}\n\n`),
+ (smtm) => smtm({ status: 4, data: 'ping' })
)
}
function ipcMultiPingTest(job, toggleIPC) {
- return toggleIPC(
- (msg, closeIPC) => {
+ return toggleIPC((msg) => {
console.log(`\n\n${msg}\n\n`)
- closeIPC(
- toggleIPC(
- (msg, closeIPC) => {
- console.log(`\n\n${msg}\n\n`)
- closeIPC()
- }, (smtm) => smtm({ status: 4, data: 'ping' })
- )
+ return toggleIPC(
+ (msg) => console.log(`\n\n${msg}\n\n`),
+ (smtm) => smtm({ status: 4, data: 'ping' })
)
}, (smtm) => smtm({ status: 4, data: 'ping' })
)