docs: enhance documentation
[poolifier.git] / src / pools / cluster / fixed.ts
index b8a73e4b0562fff6fbca6f48cab4b582c3c5a562..81e7b3b7d08b4bb5624d993a15f7850d9d3bf2ba 100644 (file)
@@ -3,7 +3,7 @@ import cluster from 'node:cluster'
 import type { MessageValue } from '../../utility-types'
 import { AbstractPool } from '../abstract-pool'
 import type { PoolOptions } from '../pool'
-import { PoolType } from '../pool-internal'
+import { PoolType } from '../pool'
 
 /**
  * Options for a poolifier cluster pool.
@@ -55,53 +55,58 @@ export class FixedClusterPool<
     super(numberOfWorkers, filePath, opts)
   }
 
-  /** {@inheritDoc} */
+  /** @inheritDoc */
   protected setupHook (): void {
     cluster.setupPrimary({ ...this.opts.settings, exec: this.filePath })
   }
 
-  /** {@inheritDoc} */
+  /** @inheritDoc */
   protected isMain (): boolean {
     return cluster.isPrimary
   }
 
-  /** {@inheritDoc} */
+  /** @inheritDoc */
   public destroyWorker (worker: Worker): void {
     this.sendToWorker(worker, { kill: 1 })
     worker.kill()
   }
 
-  /** {@inheritDoc} */
+  /** @inheritDoc */
   protected sendToWorker (worker: Worker, message: MessageValue<Data>): void {
     worker.send(message)
   }
 
-  /** {@inheritDoc} */
-  public registerWorkerMessageListener<Message extends Data | Response>(
+  /** @inheritDoc */
+  protected registerWorkerMessageListener<Message extends Data | Response>(
     worker: Worker,
     listener: (message: MessageValue<Message>) => void
   ): void {
     worker.on('message', listener)
   }
 
-  /** {@inheritDoc} */
+  /** @inheritDoc */
   protected createWorker (): Worker {
     return cluster.fork(this.opts.env)
   }
 
-  /** {@inheritDoc} */
+  /** @inheritDoc */
   protected afterWorkerSetup (worker: Worker): void {
     // Listen to worker messages.
     this.registerWorkerMessageListener(worker, super.workerListener())
   }
 
-  /** {@inheritDoc} */
+  /** @inheritDoc */
   public get type (): PoolType {
     return PoolType.FIXED
   }
 
-  /** {@inheritDoc} */
-  public get busy (): boolean {
-    return this.internalGetBusyStatus()
+  /** @inheritDoc */
+  protected get full (): boolean {
+    return this.workerNodes.length === this.numberOfWorkers
+  }
+
+  /** @inheritDoc */
+  protected get busy (): boolean {
+    return this.internalBusy()
   }
 }