X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fworker%2Fcluster-worker.ts;h=8725dc89397c08d4b1e792333fd9fe08cd75ef62;hb=3db6a2b42ee697b6f587b0f41020771941a65e68;hp=4f5fbb6b2ea87dcb54227b6b06576d80dba9c849;hpb=38e795c12f0e9daeff7b025147f36f85f486366e;p=poolifier.git diff --git a/src/worker/cluster-worker.ts b/src/worker/cluster-worker.ts index 4f5fbb6b..8725dc89 100644 --- a/src/worker/cluster-worker.ts +++ b/src/worker/cluster-worker.ts @@ -1,6 +1,6 @@ -import type { Worker } from 'cluster' -import cluster from 'cluster' -import type { MessageValue } from '../utility-types' +import type { Worker } from 'node:cluster' +import cluster from 'node:cluster' +import type { MessageValue, WorkerFunction } from '../utility-types' import { AbstractWorker } from './abstract-worker' import type { WorkerOptions } from './worker-options' @@ -28,7 +28,10 @@ export class ClusterWorker< * @param fn - Function processed by the worker when the pool's `execution` function is invoked. * @param opts - Options for the worker. */ - public constructor (fn: (data: Data) => Response, opts: WorkerOptions = {}) { + public constructor ( + fn: WorkerFunction, + opts: WorkerOptions = {} + ) { super( 'worker-cluster-pool:poolifier', cluster.isPrimary, @@ -38,12 +41,12 @@ export class ClusterWorker< ) } - /** {@inheritDoc} */ + /** @inheritDoc */ protected sendToMainWorker (message: MessageValue): void { this.getMainWorker().send(message) } - /** {@inheritDoc} */ + /** @inheritDoc */ protected handleError (e: Error | string): string { return e instanceof Error ? e.message : e }