worker-communication
This module provide bilateral communication with callback between cluster worker and master, node.js child process is supported too.
Installation
npm i worker-communication
Usage
Master
;;// or childProcess from 'child_process' const cpc = ; const worker = cpc// or cpc.tunnel(childProcess.fork('./worker.js')); cpc; worker;
child_process.fork()
)
Worker (cluster worker or ; const cpc = ; cpc; let reqHeader = 123 456; cpc;
Note
Master & worker is relative, a worker can also be a master to the process it forks.
So in this scenario, onMater()
and onWorker()
can be used at the same time to communicate its master and worker.