chore: generate documentation
[poolifier.git] / src / pools / pool.ts
index 0a015476f3af30e9750b092aadbd428282784b3f..89559d2c9a1bf0e6694709d3908a0263af0c448e 100644 (file)
@@ -1,4 +1,4 @@
-import EventEmitter from 'node:events'
+import EventEmitterAsyncResource from 'node:events'
 import type {
   ErrorHandler,
   ExitHandler,
@@ -32,14 +32,15 @@ export enum PoolType {
 /**
  * Pool events emitter.
  */
-export class PoolEmitter extends EventEmitter {}
+export class PoolEmitter extends EventEmitterAsyncResource {}
 
 /**
  * Enumeration of pool events.
  */
 export const PoolEvents = Object.freeze({
   full: 'full',
-  busy: 'busy'
+  busy: 'busy',
+  error: 'error'
 } as const)
 
 /**
@@ -91,6 +92,10 @@ export interface PoolOptions<Worker extends IWorker> {
    * The worker choice strategy options.
    */
   workerChoiceStrategyOptions?: WorkerChoiceStrategyOptions
+  /**
+   * Restart worker on error.
+   */
+  restartWorkerOnError?: boolean
   /**
    * Pool events emission.
    *
@@ -142,6 +147,7 @@ export interface IPool<
    *
    * - `'full'`: Emitted when the pool is dynamic and full.
    * - `'busy'`: Emitted when the pool is busy.
+   * - `'error'`: Emitted when an error occurs.
    */
   readonly emitter?: PoolEmitter
   /**