X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Fworker%2Fcluster-worker.ts;h=1d2729812f905d9f9724e5bf9106358ae8aa893a;hb=d4aeae5aa9e260c8c2f6d28f3133de368552c108;hp=4f5fbb6b2ea87dcb54227b6b06576d80dba9c849;hpb=ed6dd37f9e137cf659523d9d792f0171eedcb8ed;p=poolifier.git diff --git a/src/worker/cluster-worker.ts b/src/worker/cluster-worker.ts index 4f5fbb6b..1d272981 100644 --- a/src/worker/cluster-worker.ts +++ b/src/worker/cluster-worker.ts @@ -1,5 +1,5 @@ -import type { Worker } from 'cluster' -import cluster from 'cluster' +import type { Worker } from 'node:cluster' +import cluster from 'node:cluster' import type { MessageValue } 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: (data: Data) => Response | Promise, + 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 }