refactor: cleanup exports
[poolifier.git] / src / pools / cluster / fixed.ts
index 5f067bd7fb4a716f20297f2c907c7632a9607a1b..46cabdcb75787700bab966bed3ce3312056659ad 100644 (file)
@@ -1,27 +1,9 @@
-import cluster, { type ClusterSettings, type Worker } from 'node:cluster'
+import cluster, { type Worker } from 'node:cluster'
 import type { MessageValue } from '../../utility-types'
 import { AbstractPool } from '../abstract-pool'
 import { type PoolOptions, type PoolType, PoolTypes } from '../pool'
 import { type WorkerType, WorkerTypes } from '../worker'
 
-/**
- * Options for a poolifier cluster pool.
- */
-export interface ClusterPoolOptions extends PoolOptions<Worker> {
-  /**
-   * Key/value pairs to add to worker process environment.
-   *
-   * @see https://nodejs.org/api/cluster.html#cluster_cluster_fork_env
-   */
-  env?: Record<string, unknown>
-  /**
-   * Cluster settings.
-   *
-   * @see https://nodejs.org/api/cluster.html#cluster_cluster_settings
-   */
-  settings?: ClusterSettings
-}
-
 /**
  * A cluster pool with a fixed number of workers.
  *
@@ -44,7 +26,7 @@ export class FixedClusterPool<
   public constructor (
     numberOfWorkers: number,
     filePath: string,
-    protected readonly opts: ClusterPoolOptions = {}
+    protected readonly opts: PoolOptions<Worker> = {}
   ) {
     super(numberOfWorkers, filePath, opts)
   }
@@ -59,26 +41,6 @@ export class FixedClusterPool<
     return cluster.isPrimary
   }
 
-  /** @inheritDoc */
-  protected async destroyWorkerNode (workerNodeKey: number): Promise<void> {
-    this.flagWorkerNodeAsNotReady(workerNodeKey)
-    this.flushTasksQueue(workerNodeKey)
-    // FIXME: wait for tasks to be finished
-    const workerNode = this.workerNodes[workerNodeKey]
-    const worker = workerNode.worker
-    const waitWorkerExit = new Promise<void>(resolve => {
-      worker.once('exit', () => {
-        resolve()
-      })
-    })
-    worker.once('disconnect', () => {
-      worker.kill()
-    })
-    await this.sendKillMessageToWorker(workerNodeKey)
-    worker.disconnect()
-    await waitWorkerExit
-  }
-
   /** @inheritDoc */
   protected sendToWorker (
     workerNodeKey: number,
@@ -121,11 +83,6 @@ export class FixedClusterPool<
     this.workerNodes[workerNodeKey].worker.off('message', listener)
   }
 
-  /** @inheritDoc */
-  protected createWorker (): Worker {
-    return cluster.fork(this.opts.env)
-  }
-
   /** @inheritDoc */
   protected get type (): PoolType {
     return PoolTypes.fixed