X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fpools%2Fcluster%2Ffixed.ts;h=bf61cd477b153af111d835a0371d193d92ceb786;hb=260bb73734384fc982006e15359ca1c43463cc55;hp=63f129f6a7d09323db3390ffdd61b1fd6918c1d4;hpb=f8b3d84c1c95773a1e18d2c025d89d73c4f2ab15;p=poolifier.git diff --git a/src/pools/cluster/fixed.ts b/src/pools/cluster/fixed.ts index 63f129f6..bf61cd47 100644 --- a/src/pools/cluster/fixed.ts +++ b/src/pools/cluster/fixed.ts @@ -1,8 +1,9 @@ import cluster, { type Worker } from 'node:cluster' -import type { MessageValue } from '../../utility-types' -import { AbstractPool } from '../abstract-pool' -import { type PoolOptions, type PoolType, PoolTypes } from '../pool' -import { type WorkerType, WorkerTypes } from '../worker' + +import type { MessageValue } from '../../utility-types.js' +import { AbstractPool } from '../abstract-pool.js' +import { type PoolOptions, type PoolType, PoolTypes } from '../pool.js' +import { type WorkerType, WorkerTypes } from '../worker.js' /** * Options for a poolifier cluster pool. @@ -11,7 +12,6 @@ export type ClusterPoolOptions = PoolOptions /** * A cluster pool with a fixed number of workers. - * * @typeParam Data - Type of data sent to the worker. This can only be structured-cloneable data. * @typeParam Response - Type of execution response. This can only be structured-cloneable data. * @author [Christopher Quadflieg](https://github.com/Shinigami92) @@ -23,10 +23,10 @@ export class FixedClusterPool< > extends AbstractPool { /** * Constructs a new poolifier fixed cluster pool. - * * @param numberOfWorkers - Number of workers for this pool. * @param filePath - Path to an implementation of a `ClusterWorker` file, which can be relative or absolute. * @param opts - Options for this fixed cluster pool. + * @param maximumNumberOfWorkers - The maximum number of workers for this pool. */ public constructor ( numberOfWorkers: number, @@ -52,16 +52,16 @@ export class FixedClusterPool< workerNodeKey: number, message: MessageValue ): void { - this.workerNodes[workerNodeKey].worker.send({ + this.workerNodes[workerNodeKey]?.worker.send({ ...message, - workerId: this.getWorkerInfo(workerNodeKey).id as number - }) + workerId: this.getWorkerInfo(workerNodeKey)?.id, + } satisfies MessageValue) } /** @inheritDoc */ protected sendStartupMessageToWorker (workerNodeKey: number): void { this.sendToWorker(workerNodeKey, { - ready: false + ready: false, }) }