import cluster, { type Worker } from 'node:cluster'
+
import type { MessageValue } from '../utility-types.js'
import { AbstractWorker } from './abstract-worker.js'
-import type { WorkerOptions } from './worker-options.js'
import type { TaskFunction, TaskFunctions } from './task-functions.js'
+import type { WorkerOptions } from './worker-options.js'
/**
* A cluster worker used by a poolifier `ClusterPool`.
this.getMainWorker().on('message', this.messageListener.bind(this))
this.sendToMainWorker({
ready: true,
- taskFunctionNames: this.listTaskFunctionNames()
+ taskFunctionsProperties: this.listTaskFunctionsProperties()
})
} catch {
this.sendToMainWorker({
ready: false,
- taskFunctionNames: this.listTaskFunctionNames()
+ taskFunctionsProperties: this.listTaskFunctionsProperties()
})
}
}
protected readonly sendToMainWorker = (
message: MessageValue<Response>
): void => {
- this.getMainWorker().send({ ...message, workerId: this.id })
+ this.getMainWorker().send({
+ ...message,
+ workerId: this.id
+ } satisfies MessageValue<Response>)
}
}