-import type { Worker } from 'cluster'
+import type { ClusterSettings, Worker } from 'cluster'
import cluster from 'cluster'
import type { MessageValue } from '../../utility-types'
import { AbstractPool } from '../abstract-pool'
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
env?: any
+ /**
+ * Cluster settings.
+ *
+ * @see https://nodejs.org/api/cluster.html#cluster_cluster_settings
+ */
+ settings?: ClusterSettings
}
/**
*
* This pool selects the workers in a round robin fashion.
*
- * @template DataType of data sent to the worker. This can only be serializable data.
- * @template ResponseType of response of execution. This can only be serializable data.
+ * @template Data Type of data sent to the worker. This can only be serializable data.
+ * @template Response Type of response of execution. This can only be serializable data.
* @author [Christopher Quadflieg](https://github.com/Shinigami92)
* @since 2.0.0
*/
*
* @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 opts Options for this fixed cluster pool.
*/
public constructor (
numberOfWorkers: number,
/** @inheritDoc */
protected setupHook (): void {
- cluster.setupPrimary({
- exec: this.filePath
- })
+ cluster.setupPrimary({ ...this.opts.settings, exec: this.filePath })
}
/** @inheritDoc */
/** @inheritDoc */
protected afterWorkerSetup (worker: Worker): void {
- // Listen worker messages.
+ // Listen to worker messages.
this.registerWorkerMessageListener(worker, super.workerListener())
}