From 4c7c767b9ed625eee3e28f34bda8e63ecc4391b4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Tue, 3 Oct 2023 11:26:38 +0200 Subject: [PATCH] feat: emit started/stopped event on worker set MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- src/worker/WorkerSet.ts | 2 ++ src/worker/WorkerTypes.ts | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/worker/WorkerSet.ts b/src/worker/WorkerSet.ts index 5f10f090..c5df860c 100644 --- a/src/worker/WorkerSet.ts +++ b/src/worker/WorkerSet.ts @@ -78,6 +78,7 @@ export class WorkerSet extends WorkerAbstract { // Add worker set element sequentially to optimize memory at startup this.workerOptions.workerStartDelay! > 0 && (await sleep(randomizeDelay(this.workerOptions.workerStartDelay!))); + this.emitter?.emit(WorkerSetEvents.started, this.info); this.started = true; } @@ -92,6 +93,7 @@ export class WorkerSet extends WorkerAbstract { }); await worker.terminate(); await waitWorkerExit; + this.emitter?.emit(WorkerSetEvents.stopped, this.info); this.emitter?.emitDestroy(); this.started = false; } diff --git a/src/worker/WorkerTypes.ts b/src/worker/WorkerTypes.ts index 806808d8..cfbe2dac 100644 --- a/src/worker/WorkerTypes.ts +++ b/src/worker/WorkerTypes.ts @@ -19,6 +19,8 @@ export interface SetInfo { } export enum WorkerSetEvents { + started = 'started', + stopped = 'stopped', error = 'error', elementStarted = 'elementStarted', elementError = 'elementError', -- 2.34.1