From: Jérôme Benoit Date: Fri, 7 Apr 2023 14:25:20 +0000 (+0200) Subject: refactor: refine worker options scope X-Git-Tag: v2.4.3~2 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=d99ba5a8a292772965b5027272a8dc677a6ad008;p=poolifier.git refactor: refine worker options scope Signed-off-by: Jérôme Benoit --- diff --git a/src/pools/abstract-pool.ts b/src/pools/abstract-pool.ts index 68e83371..97225246 100644 --- a/src/pools/abstract-pool.ts +++ b/src/pools/abstract-pool.ts @@ -248,11 +248,12 @@ export abstract class AbstractPool< /** * Setup hook that can be overridden by a Poolifier pool implementation * to run code before workers are created in the abstract constructor. + * Can be overridden * * @virtual */ protected setupHook (): void { - // Can be overridden + // Intentionally empty } /** diff --git a/src/pools/pool-internal.ts b/src/pools/pool-internal.ts index 095e954e..ddfcc41e 100644 --- a/src/pools/pool-internal.ts +++ b/src/pools/pool-internal.ts @@ -3,6 +3,8 @@ import type { IPoolWorker } from './pool-worker' /** * Internal pool types. + * + * @enum */ export enum PoolType { FIXED = 'fixed', diff --git a/src/worker/abstract-worker.ts b/src/worker/abstract-worker.ts index 51654179..475595ec 100644 --- a/src/worker/abstract-worker.ts +++ b/src/worker/abstract-worker.ts @@ -29,10 +29,6 @@ export abstract class AbstractWorker< * Handler Id of the `aliveInterval` worker alive check. */ protected readonly aliveInterval?: NodeJS.Timeout - /** - * Options for the worker. - */ - public readonly opts: WorkerOptions /** * Constructs a new poolifier worker. * @@ -47,7 +43,7 @@ export abstract class AbstractWorker< protected readonly isMain: boolean, fn: (data: Data) => Response, protected mainWorker: MainWorker | undefined | null, - opts: WorkerOptions = { + protected readonly opts: WorkerOptions = { /** * The kill behavior option on this Worker or its default value. */ @@ -60,7 +56,6 @@ export abstract class AbstractWorker< } ) { super(type) - this.opts = opts this.checkFunctionInput(fn) this.checkWorkerOptions(this.opts) if (!this.isMain) {