Im a bit new to Node.js so I have a question about handling response in express.js
Lets say I have a cluster with master and 2 workers. In worker I get a request and I call master to get me a status update
In worker I have
router.get('/status/:file', function(req, res) {
process.send({ status: req.params.file});
});
it lands in master fork part
var worker = cluster.fork();
worker.on('message', function(msg) {
if (msg.status) {
//check the queue... do something and send it back to worker
worker.send({ status: true});
}
});
so worker catches that in
process.on('message', function(msg) {
if (msg.status) {
// How do I reference response here??
res.send ({status:msg.status})
}
});
So how do i keep reference to original res from router?
Can I do anonymous function, add callback to res or something else?