X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fpools%2Fabstract-pool.ts;h=538d66c797fabc98e93a130953fdde2ee9edfdc8;hb=8881ae32256c9a9ebe6d78c95672f610a3f46719;hp=58fc28ce12d6a56416b6db05cec3e5186c549a14;hpb=f8350486e75b15ed17249cda3d0a55ee807a6a9f;p=poolifier.git diff --git a/src/pools/abstract-pool.ts b/src/pools/abstract-pool.ts index 58fc28ce..538d66c7 100644 --- a/src/pools/abstract-pool.ts +++ b/src/pools/abstract-pool.ts @@ -17,7 +17,8 @@ import { type PoolOptions, type PoolType, PoolTypes, - type TasksQueueOptions + type TasksQueueOptions, + type WorkerType } from './pool' import type { IWorker, Task, TasksUsage, WorkerNode } from './worker' import { @@ -210,13 +211,11 @@ export abstract class AbstractPool< } } - /** @inheritDoc */ - public abstract get type (): PoolType - /** @inheritDoc */ public get info (): PoolInfo { return { type: this.type, + worker: this.worker, minSize: this.minSize, maxSize: this.maxSize, workerNodes: this.workerNodes.length, @@ -247,6 +246,18 @@ export abstract class AbstractPool< } } + /** + * Pool type. + * + * If it is `'dynamic'`, it provides the `max` property. + */ + protected abstract get type (): PoolType + + /** + * Gets the worker type. + */ + protected abstract get worker (): WorkerType + /** * Pool minimum size. */ @@ -403,6 +414,7 @@ export abstract class AbstractPool< await Promise.all( this.workerNodes.map(async (workerNode, workerNodeKey) => { this.flushTasksQueue(workerNodeKey) + // FIXME: wait for tasks to be finished await this.destroyWorker(workerNode.worker) }) ) @@ -528,6 +540,7 @@ export abstract class AbstractPool< ) { // Kill message received from the worker: no new tasks are submitted to that worker for a while ( > maxInactiveTime) this.flushTasksQueue(currentWorkerNodeKey) + // FIXME: wait for tasks to be finished void (this.destroyWorker(workerCreated) as Promise) } })