X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fpools%2Fselection-strategies.ts;h=f1c20befd6b709784f08f5fe339709d2bf3b1e3d;hb=e00a6c53e0d42d4b76791441975b70888ead0a73;hp=64ea7ee58509057d6cae4e235b07350f8f087e41;hpb=036c58dd9dc083da22c5fc39036a2ff49d10dc49;p=poolifier.git diff --git a/src/pools/selection-strategies.ts b/src/pools/selection-strategies.ts index 64ea7ee5..f1c20bef 100644 --- a/src/pools/selection-strategies.ts +++ b/src/pools/selection-strategies.ts @@ -41,8 +41,7 @@ interface IWorkerChoiceStrategy { * @template Response Type of response of execution. This can only be serializable data. */ class RoundRobinWorkerChoiceStrategy - implements IWorkerChoiceStrategy -{ + implements IWorkerChoiceStrategy { /** * Index for the next worker. */ @@ -61,7 +60,7 @@ class RoundRobinWorkerChoiceStrategy public choose (): Worker { const chosenWorker = this.pool.workers[this.nextWorkerIndex] this.nextWorkerIndex = - this.pool.workers.length - 1 === this.nextWorkerIndex + this.nextWorkerIndex === this.pool.workers.length - 1 ? 0 : this.nextWorkerIndex + 1 return chosenWorker @@ -79,8 +78,7 @@ class LessRecentlyUsedWorkerChoiceStrategy< Worker extends IWorker, Data, Response -> implements IWorkerChoiceStrategy -{ +> implements IWorkerChoiceStrategy { /** * Constructs a worker choice strategy that selects based on less recently used. * @@ -116,8 +114,7 @@ class LessRecentlyUsedWorkerChoiceStrategy< * @template Response Type of response of execution. This can only be serializable data. */ class DynamicPoolWorkerChoiceStrategy - implements IWorkerChoiceStrategy -{ + implements IWorkerChoiceStrategy { private workerChoiceStrategy: IWorkerChoiceStrategy /** @@ -132,11 +129,10 @@ class DynamicPoolWorkerChoiceStrategy private createDynamicallyWorkerCallback: () => Worker, workerChoiceStrategy: WorkerChoiceStrategy = WorkerChoiceStrategies.ROUND_ROBIN ) { - this.workerChoiceStrategy = - SelectionStrategiesUtils.getWorkerChoiceStrategy( - this.pool, - workerChoiceStrategy - ) + this.workerChoiceStrategy = SelectionStrategiesUtils.getWorkerChoiceStrategy( + this.pool, + workerChoiceStrategy + ) } /** @inheritdoc */ @@ -215,8 +211,9 @@ export class WorkerChoiceStrategyContext< public setWorkerChoiceStrategy ( workerChoiceStrategy: WorkerChoiceStrategy ): void { - this.workerChoiceStrategy = - this.getPoolWorkerChoiceStrategy(workerChoiceStrategy) + this.workerChoiceStrategy = this.getPoolWorkerChoiceStrategy( + workerChoiceStrategy + ) } /** @@ -255,6 +252,7 @@ class SelectionStrategiesUtils { return new LessRecentlyUsedWorkerChoiceStrategy(pool) default: throw new Error( + // eslint-disable-next-line @typescript-eslint/restrict-template-expressions `Worker choice strategy '${workerChoiceStrategy}' not found` ) }