super(
'worker-cluster-pool:poolifier',
cluster.isPrimary,
- taskFunctions,
cluster.worker as Worker,
+ taskFunctions,
opts
)
- if (!this.isMain) {
- this.sendToMainWorker({ workerId: this.id, started: true })
+ }
+
+ /** @inheritDoc */
+ protected handleReadyMessage (message: MessageValue<Data>): void {
+ if (!this.isMain && message.workerId === this.id && message.ready != null) {
+ this.getMainWorker()?.on('message', this.messageListener.bind(this))
+ this.sendToMainWorker({ ready: true, workerId: this.id })
}
}
/** @inheritDoc */
protected sendToMainWorker (message: MessageValue<Response>): void {
- console.log('sending message to main worker(cluster)', message)
this.getMainWorker().send(message)
}
-
- /** @inheritDoc */
- protected handleError (e: Error | string): string {
- return e instanceof Error ? e.message : e
- }
}