repositories
/
poolifier.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fix: fix workey weights input validation
[poolifier.git]
/
src
/
pools
/
abstract-pool.ts
diff --git
a/src/pools/abstract-pool.ts
b/src/pools/abstract-pool.ts
index 5114bead6d4670af440b5d66f5af22bfa5aa213f..eab110d8ec4d2200ec78320383874abbf333562a 100644
(file)
--- a/
src/pools/abstract-pool.ts
+++ b/
src/pools/abstract-pool.ts
@@
-146,6
+146,9
@@
export abstract class AbstractPool<
this.opts.workerChoiceStrategyOptions =
opts.workerChoiceStrategyOptions ??
DEFAULT_WORKER_CHOICE_STRATEGY_OPTIONS
this.opts.workerChoiceStrategyOptions =
opts.workerChoiceStrategyOptions ??
DEFAULT_WORKER_CHOICE_STRATEGY_OPTIONS
+ this.checkValidWorkerChoiceStrategyOptions(
+ this.opts.workerChoiceStrategyOptions
+ )
this.opts.enableEvents = opts.enableEvents ?? true
this.opts.enableTasksQueue = opts.enableTasksQueue ?? false
if (this.opts.enableTasksQueue) {
this.opts.enableEvents = opts.enableEvents ?? true
this.opts.enableTasksQueue = opts.enableTasksQueue ?? false
if (this.opts.enableTasksQueue) {
@@
-179,6
+182,14
@@
export abstract class AbstractPool<
'Invalid worker choice strategy options: must be a plain object'
)
}
'Invalid worker choice strategy options: must be a plain object'
)
}
+ if (
+ workerChoiceStrategyOptions.weights != null &&
+ Object.keys(workerChoiceStrategyOptions.weights).length !== this.size
+ ) {
+ throw new Error(
+ 'Invalid worker choice strategy options: must have a weight for each worker node'
+ )
+ }
}
private checkValidTasksQueueOptions (
}
private checkValidTasksQueueOptions (