X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fworker%2Fcluster-worker.ts;h=847f2174d1657b05824d12461b8bba054287ae54;hb=910416386b4f7d0da4e6f0d8551cefa2539c5ced;hp=d972692ec6eb4f182479cac008c47a1f20b75d8d;hpb=803f948f302ce93b89b93b875bef173f2a87c5fc;p=poolifier.git diff --git a/src/worker/cluster-worker.ts b/src/worker/cluster-worker.ts index d972692e..847f2174 100644 --- a/src/worker/cluster-worker.ts +++ b/src/worker/cluster-worker.ts @@ -1,8 +1,9 @@ import cluster, { type Worker } from 'node:cluster' -import type { MessageValue } from '../utility-types' -import { AbstractWorker } from './abstract-worker' -import type { WorkerOptions } from './worker-options' -import type { TaskFunction, TaskFunctions } from './task-functions' + +import type { MessageValue } from '../utility-types.js' +import { AbstractWorker } from './abstract-worker.js' +import type { TaskFunction, TaskFunctions } from './task-functions.js' +import type { WorkerOptions } from './worker-options.js' /** * A cluster worker used by a poolifier `ClusterPool`. @@ -32,7 +33,7 @@ export class ClusterWorker< taskFunctions: TaskFunction | TaskFunctions, opts: WorkerOptions = {} ) { - super(cluster.isPrimary, cluster.worker as Worker, taskFunctions, opts) + super(cluster.isPrimary, cluster.worker, taskFunctions, opts) } /** @inheritDoc */ @@ -42,12 +43,12 @@ export class ClusterWorker< 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() }) } } @@ -62,6 +63,9 @@ export class ClusterWorker< protected readonly sendToMainWorker = ( message: MessageValue ): void => { - this.getMainWorker().send({ ...message, workerId: this.id }) + this.getMainWorker().send({ + ...message, + workerId: this.id + } satisfies MessageValue) } }