feat: restart worker in case of uncaught error
[poolifier.git] / src / pools / pool.ts
index 14b30812d14bd21e55c0af4aee77db5daf8bc7e4..89559d2c9a1bf0e6694709d3908a0263af0c448e 100644 (file)
@@ -39,7 +39,8 @@ export class PoolEmitter extends EventEmitterAsyncResource {}
  */
 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
   /**