From: Jérôme Benoit Date: Fri, 17 Nov 2023 20:11:03 +0000 (+0100) Subject: refactor: use object destructuration for task execution response X-Git-Tag: v3.0.6~20 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=51af50ef7ad06da0f7d71c7985a251e48b97c434;p=poolifier.git refactor: use object destructuration for task execution response Signed-off-by: Jérôme Benoit --- diff --git a/src/pools/abstract-pool.ts b/src/pools/abstract-pool.ts index b09b81ae..94902356 100644 --- a/src/pools/abstract-pool.ts +++ b/src/pools/abstract-pool.ts @@ -1585,13 +1585,13 @@ export abstract class AbstractPool< const { taskId, workerError, data } = message const promiseResponse = this.promiseResponseMap.get(taskId as string) if (promiseResponse != null) { + const { resolve, reject, workerNodeKey } = promiseResponse if (workerError != null) { this.emitter?.emit(PoolEvents.taskError, workerError) - promiseResponse.reject(workerError.message) + reject(workerError.message) } else { - promiseResponse.resolve(data as Response) + resolve(data as Response) } - const workerNodeKey = promiseResponse.workerNodeKey this.afterTaskExecutionHook(workerNodeKey, message) this.workerChoiceStrategyContext.update(workerNodeKey) this.promiseResponseMap.delete(taskId as string)