taskFunctions: TaskFunction<Data, Response> | TaskFunctions<Data, Response>,
opts: WorkerOptions = {}
) {
- super(
- 'worker-cluster-pool:poolifier',
- cluster.isPrimary,
- cluster.worker as Worker,
- taskFunctions,
- opts
- )
+ super(cluster.isPrimary, cluster.worker as Worker, taskFunctions, opts)
}
/** @inheritDoc */
this.getMainWorker().on('message', this.messageListener.bind(this))
this.sendToMainWorker({
ready: true,
- taskFunctionNames: this.listTaskFunctionNames(),
- workerId: this.id
+ taskFunctionNames: this.listTaskFunctionNames()
})
} catch {
this.sendToMainWorker({
ready: false,
- taskFunctionNames: this.listTaskFunctionNames(),
- workerId: this.id
+ taskFunctionNames: this.listTaskFunctionNames()
})
}
}
}
/** @inheritDoc */
- protected sendToMainWorker (message: MessageValue<Response>): void {
- this.getMainWorker().send(message)
+ protected readonly sendToMainWorker = (
+ message: MessageValue<Response>
+ ): void => {
+ this.getMainWorker().send({ ...message, workerId: this.id })
}
}