-
-
Notifications
You must be signed in to change notification settings - Fork 314
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
v6.6.0 - Added ability for processes to easily respond to messages ov…
…er IPC via callbacks
- Loading branch information
Showing
16 changed files
with
348 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
|
||
module.exports.run = function (broker) { | ||
console.log(' >> Broker PID:', process.pid); | ||
|
||
broker.on('masterMessage', function (data, res) { | ||
console.log(`BROKER ${broker.id}::Received data from master:`, data); | ||
if (data.fail) { | ||
var err = new Error('This is an error from broker'); | ||
err.name = 'MyCustomBrokerError'; | ||
res(err); | ||
} else if (!data.doNothing) { | ||
res(null, { | ||
id: 1, | ||
name: 'TestName' | ||
}); | ||
} | ||
}); | ||
|
||
var packet = { | ||
prop: 1234 | ||
}; | ||
|
||
console.log(`BROKER ${broker.id}::Sending packet to master`); | ||
broker.sendToMaster(packet, function (err, data) { | ||
console.log(`BROKER ${broker.id}::Response error from master:`, err); | ||
console.log(`BROKER ${broker.id}::Response data packet from master:`, data); | ||
}); | ||
|
||
var timeoutPacket = { | ||
doNothing: true | ||
}; | ||
|
||
console.log(`BROKER ${broker.id}::Sending timeout-causing packet to master`); | ||
broker.sendToMaster(timeoutPacket, function (err, data) { | ||
console.log(`BROKER ${broker.id}::Timeout response error from master:`, err); | ||
console.log(`BROKER ${broker.id}::Timeout response data packet from master:`, data); | ||
}); | ||
|
||
var errorPacket = { | ||
fail: true | ||
}; | ||
|
||
console.log(`BROKER ${broker.id}::Sending error-causing packet to master`); | ||
broker.sendToMaster(errorPacket, function (err, data) { | ||
console.log(`BROKER ${broker.id}::Error response error from master:`, err); | ||
console.log(`BROKER ${broker.id}::Error response data packet from master:`, data); | ||
}); | ||
|
||
console.log(`BROKER ${broker.id}::Sending error-causing packet to master without callback`); | ||
broker.sendToMaster(errorPacket); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.