X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fworker%2Fcluster-worker.ts;h=4b1efaca384a92869b67460236aefea72953df9d;hb=838898f1dfd2d2456d3e9a832d24a7ef6f53be70;hp=9402ec1044e51ce9a42c8717e3c6c506dda1ac10;hpb=472bf1f5aa50f29e44d194437964127f3bd0e3f4;p=poolifier.git diff --git a/src/worker/cluster-worker.ts b/src/worker/cluster-worker.ts index 9402ec10..4b1efaca 100644 --- a/src/worker/cluster-worker.ts +++ b/src/worker/cluster-worker.ts @@ -30,27 +30,7 @@ export class ClusterWorker< * @param opts Options for the worker. */ public constructor (fn: (data: Data) => Response, opts: WorkerOptions = {}) { - super('worker-cluster-pool:pioardi', isMaster, fn, opts) - - worker.on('message', (value: MessageValue) => { - if (value?.data && value.id) { - // here you will receive messages - // console.log('This is the main worker ' + isMaster) - if (this.async) { - this.runInAsyncScope(this.runAsync.bind(this), this, fn, value) - } else { - this.runInAsyncScope(this.run.bind(this), this, fn, value) - } - } else if (value.kill) { - // here is time to kill this worker, just clearing the interval - if (this.interval) clearInterval(this.interval) - this.emitDestroy() - } - }) - } - - protected getMainWorker (): Worker { - return worker + super('worker-cluster-pool:pioardi', isMaster, fn, worker, opts) } protected sendToMainWorker (message: MessageValue): void {