/** @inheritDoc */
public setOptions (opts: InternalWorkerChoiceStrategyOptions): void {
this.opts = {
- ...getDefaultInternalWorkerChoiceStrategyOptions(this.pool.info.maxSize),
+ ...getDefaultInternalWorkerChoiceStrategyOptions(
+ this.pool.info.maxSize +
+ Object.keys((opts?.weights as Record<number, number>) ?? {}).length
+ ),
...opts
}
this.setTaskStatisticsRequirements(this.opts)
private opts?: InternalWorkerChoiceStrategyOptions
) {
this.opts = {
- ...getDefaultInternalWorkerChoiceStrategyOptions(pool.info.maxSize),
+ ...getDefaultInternalWorkerChoiceStrategyOptions(
+ pool.info.maxSize +
+ Object.keys((this.opts?.weights as Record<number, number>) ?? {})
+ .length
+ ),
...this.opts
}
this.execute = this.execute.bind(this)
opts?: InternalWorkerChoiceStrategyOptions
): void {
this.opts = {
- ...getDefaultInternalWorkerChoiceStrategyOptions(pool.info.maxSize),
+ ...getDefaultInternalWorkerChoiceStrategyOptions(
+ pool.info.maxSize +
+ Object.keys((opts?.weights as Record<number, number>) ?? {}).length
+ ),
...opts
}
for (const workerChoiceStrategy of this.workerChoiceStrategies.values()) {
})
/**
- * Default worker choice strategy options.
+ * Gets default worker choice strategy options.
*
- * @param poolMaxSize - The pool maximum size.
+ * @param retries - The number of worker choice retries.
* @returns The default worker choice strategy options.
*/
export const getDefaultInternalWorkerChoiceStrategyOptions = (
- poolMaxSize: number
+ retries: number
): InternalWorkerChoiceStrategyOptions => {
return {
- retries: poolMaxSize,
+ retries,
runTime: { median: false },
waitTime: { median: false },
elu: { median: false }
exitHandler: testHandler
})
expect(pool.workerChoiceStrategyContext.opts).toStrictEqual({
- retries: pool.info.maxSize,
+ retries:
+ pool.info.maxSize +
+ Object.keys(pool.opts.workerChoiceStrategyOptions.weights).length,
runTime: { median: true },
waitTime: { median: false },
elu: { median: false },
for (const [, workerChoiceStrategy] of pool.workerChoiceStrategyContext
.workerChoiceStrategies) {
expect(workerChoiceStrategy.opts).toStrictEqual({
- retries: pool.info.maxSize,
+ retries:
+ pool.info.maxSize +
+ Object.keys(pool.opts.workerChoiceStrategyOptions.weights).length,
runTime: { median: true },
waitTime: { median: false },
elu: { median: false },