Currently I'm doing a nodejs project where I don't want to use any third party packages or database systems. Now I'm almost done with the project. But here's the problem. I've some authentication related functionality that needs "Sticky Load Balancing", that means I need to do all the authentication related task by the primary node.
I know, I can send message to the primary node from the child nodes using the "process.send({ --- msg object --- })" and from the primary I can do "worker.send({ -- response object -- })" to send message to child nodes.
But I need to do something like this from the child nodes:
process.send(msgObject, callback);
where I'll get the response in the callback. But all the child nodes are separate nodejs instances. I've tried to include the callback function in the msgObject but in the primary node it strips all functions from the msgObject. I read the docs and found this:
process.send(message[, sendHandle[, options]][, callback])
But there's no example of how to implement it. It says the sendHandle is of type net.Server | net.Socket. I know how to set up a basic socket server and communicate with it. But I'm not sure if it's a good idea to use a socket server to implement this communication.