test: add kill behavior testing
[poolifier.git] / src / pools / abstract-pool.ts
index 58fc28ce12d6a56416b6db05cec3e5186c549a14..631434f37618e4727b2a8dcdbee119c309965da1 100644 (file)
@@ -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 {
@@ -217,6 +218,7 @@ export abstract class AbstractPool<
   public get info (): PoolInfo {
     return {
       type: this.type,
+      worker: this.worker,
       minSize: this.minSize,
       maxSize: this.maxSize,
       workerNodes: this.workerNodes.length,
@@ -247,6 +249,11 @@ export abstract class AbstractPool<
     }
   }
 
+  /**
+   * Gets the worker type.
+   */
+  protected abstract get worker (): WorkerType
+
   /**
    * Pool minimum size.
    */
@@ -403,6 +410,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 +536,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<void>)
         }
       })