X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fpools%2Fcluster%2Fdynamic.ts;h=25940ad84340f43f3e7b0abf5cec7ddf3edbc8d4;hb=f2fdaa86fd9e6f3a5dc0b3146c065e3a7bfb44e0;hp=f2375a02d6e1babf875d27b40f01782849828af0;hpb=cda5cc74c77bdfc37b220ef19637876e221b5061;p=poolifier.git diff --git a/src/pools/cluster/dynamic.ts b/src/pools/cluster/dynamic.ts index f2375a02..25940ad8 100644 --- a/src/pools/cluster/dynamic.ts +++ b/src/pools/cluster/dynamic.ts @@ -1,5 +1,5 @@ import type { Worker } from 'cluster' -import type { MessageValue } from '../../utility-types' +import type { JSONValue, MessageValue } from '../../utility-types' import type { ClusterPoolOptions } from './fixed' import { FixedClusterPool } from './fixed' @@ -13,10 +13,8 @@ import { FixedClusterPool } from './fixed' * @since 2.0.0 */ export class DynamicClusterPool< - // eslint-disable-next-line @typescript-eslint/no-explicit-any - Data = any, - // eslint-disable-next-line @typescript-eslint/no-explicit-any - Response = any + Data extends JSONValue = JSONValue, + Response extends JSONValue = JSONValue > extends FixedClusterPool { /** * @param min Min number of workers that will be always active @@ -56,10 +54,7 @@ export class DynamicClusterPool< if (message.kill) { this.sendToWorker(worker, { kill: 1 }) void this.destroyWorker(worker) - // clean workers from data structures - const workerIndex = this.workers.indexOf(worker) - this.workers.splice(workerIndex, 1) - this.tasks.delete(worker) + this.removeWorker(worker) } }) return worker