Data = unknown,
Response = unknown
> {
- private workerChoiceStrategy: IWorkerChoiceStrategy<Worker, Data, Response>
+ private readonly workerChoiceStrategies = new Map<
+ WorkerChoiceStrategy,
+ IWorkerChoiceStrategy<Worker, Data, Response>
+ >()
/**
* Worker choice strategy context constructor.
private workerChoiceStrategyType: WorkerChoiceStrategy = WorkerChoiceStrategies.ROUND_ROBIN
) {
this.execute.bind(this)
- this.workerChoiceStrategy = this.getWorkerChoiceStrategy(
- pool,
- this.workerChoiceStrategyType
- )
+ this.registerWorkerChoiceStrategy(pool, workerChoiceStrategyType)
}
/**
* @returns The required statistics.
*/
public getRequiredStatistics (): RequiredStatistics {
- return this.workerChoiceStrategy.requiredStatistics
+ return (
+ this.workerChoiceStrategies.get(
+ this.workerChoiceStrategyType
+ ) as IWorkerChoiceStrategy<Worker, Data, Response>
+ ).requiredStatistics
}
/**
workerChoiceStrategy: WorkerChoiceStrategy
): void {
if (this.workerChoiceStrategyType === workerChoiceStrategy) {
- this.workerChoiceStrategy?.reset()
+ this.workerChoiceStrategies.get(workerChoiceStrategy)?.reset()
} else {
this.workerChoiceStrategyType = workerChoiceStrategy
- this.workerChoiceStrategy = this.getWorkerChoiceStrategy(
- pool,
- this.workerChoiceStrategyType
- )
+ this.registerWorkerChoiceStrategy(pool, workerChoiceStrategy)
}
}
* @returns The key of the chosen one.
*/
public execute (): number {
+ const workerChoiceStrategy = this.workerChoiceStrategies.get(
+ this.workerChoiceStrategyType
+ ) as IWorkerChoiceStrategy<Worker, Data, Response>
if (
- this.workerChoiceStrategy.isDynamicPool &&
- !this.workerChoiceStrategy.pool.full &&
- this.workerChoiceStrategy.pool.findFreeWorkerKey() === -1
+ workerChoiceStrategy.isDynamicPool &&
+ !workerChoiceStrategy.pool.full &&
+ workerChoiceStrategy.pool.findFreeWorkerKey() === -1
) {
return this.createWorkerCallback()
}
- return this.workerChoiceStrategy.choose()
+ return workerChoiceStrategy.choose()
}
/**
* @returns `true` if the removal is successful, `false` otherwise.
*/
public remove (workerKey: number): boolean {
- return this.workerChoiceStrategy.remove(workerKey)
+ return (
+ this.workerChoiceStrategies.get(
+ this.workerChoiceStrategyType
+ ) as IWorkerChoiceStrategy<Worker, Data, Response>
+ ).remove(workerKey)
+ }
+
+ private registerWorkerChoiceStrategy (
+ pool: IPoolInternal<Worker, Data, Response>,
+ workerChoiceStrategy: WorkerChoiceStrategy
+ ): void {
+ if (!this.workerChoiceStrategies.has(workerChoiceStrategy)) {
+ this.workerChoiceStrategies.set(
+ workerChoiceStrategy,
+ this.getWorkerChoiceStrategy(pool, workerChoiceStrategy)
+ )
+ }
}
/**
WorkerChoiceStrategies.ROUND_ROBIN
)
expect(
- pool.workerChoiceStrategyContext.workerChoiceStrategy.nextWorkerId
+ pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
+ WorkerChoiceStrategies.ROUND_ROBIN
+ ).nextWorkerId
).toBe(0)
// We need to clean up the resources after our test
await pool.destroy()
{ workerChoiceStrategy: WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN }
)
expect(
- pool.workerChoiceStrategyContext.workerChoiceStrategy.nextWorkerId
+ pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
+ WorkerChoiceStrategies.ROUND_ROBIN
+ )?.nextWorkerId
).toBeUndefined()
pool.setWorkerChoiceStrategy(WorkerChoiceStrategies.ROUND_ROBIN)
expect(
- pool.workerChoiceStrategyContext.workerChoiceStrategy.nextWorkerId
+ pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
+ WorkerChoiceStrategies.ROUND_ROBIN
+ ).nextWorkerId
).toBe(0)
await pool.destroy()
pool = new DynamicThreadPool(
{ workerChoiceStrategy: WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN }
)
expect(
- pool.workerChoiceStrategyContext.workerChoiceStrategy.nextWorkerId
+ pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
+ WorkerChoiceStrategies.ROUND_ROBIN
+ )?.nextWorkerId
).toBeUndefined()
pool.setWorkerChoiceStrategy(WorkerChoiceStrategies.ROUND_ROBIN)
expect(
- pool.workerChoiceStrategyContext.workerChoiceStrategy.nextWorkerId
+ pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
+ WorkerChoiceStrategies.ROUND_ROBIN
+ ).nextWorkerId
).toBe(0)
// We need to clean up the resources after our test
await pool.destroy()
expect(pool.opts.workerChoiceStrategy).toBe(
WorkerChoiceStrategies.FAIR_SHARE
)
- for (const workerKey of pool.workerChoiceStrategyContext.workerChoiceStrategy.workerLastVirtualTaskTimestamp.keys()) {
+ for (const workerKey of pool.workerChoiceStrategyContext.workerChoiceStrategies
+ .get(WorkerChoiceStrategies.FAIR_SHARE)
+ .workerLastVirtualTaskTimestamp.keys()) {
expect(
- pool.workerChoiceStrategyContext.workerChoiceStrategy.workerLastVirtualTaskTimestamp.get(
- workerKey
- ).start
+ pool.workerChoiceStrategyContext.workerChoiceStrategies
+ .get(WorkerChoiceStrategies.FAIR_SHARE)
+ .workerLastVirtualTaskTimestamp.get(workerKey).start
).toBe(0)
expect(
- pool.workerChoiceStrategyContext.workerChoiceStrategy.workerLastVirtualTaskTimestamp.get(
- workerKey
- ).end
+ pool.workerChoiceStrategyContext.workerChoiceStrategies
+ .get(WorkerChoiceStrategies.FAIR_SHARE)
+ .workerLastVirtualTaskTimestamp.get(workerKey).end
).toBe(0)
}
// We need to clean up the resources after our test
}
await Promise.all(promises)
expect(
- pool.workerChoiceStrategyContext.workerChoiceStrategy
- .workerLastVirtualTaskTimestamp.size
+ pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
+ WorkerChoiceStrategies.FAIR_SHARE
+ ).workerLastVirtualTaskTimestamp.size
).toBe(pool.workers.length)
// We need to clean up the resources after our test
await pool.destroy()
await Promise.all(promises)
// if (process.platform !== 'win32') {
// expect(
- // pool.workerChoiceStrategyContext.workerChoiceStrategy
- // .workerLastVirtualTaskTimestamp.size
+ // pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
+ // WorkerChoiceStrategies.FAIR_SHARE
+ // ).workerLastVirtualTaskTimestamp.size
// ).toBe(pool.workers.length)
// }
// We need to clean up the resources after our test
'./tests/worker-files/thread/testWorker.js'
)
expect(
- pool.workerChoiceStrategyContext.workerChoiceStrategy
- .workerLastVirtualTaskTimestamp
+ pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
+ WorkerChoiceStrategies.FAIR_SHARE
+ )?.workerLastVirtualTaskTimestamp
).toBeUndefined()
pool.setWorkerChoiceStrategy(WorkerChoiceStrategies.FAIR_SHARE)
- for (const workerKey of pool.workerChoiceStrategyContext.workerChoiceStrategy.workerLastVirtualTaskTimestamp.keys()) {
+ for (const workerKey of pool.workerChoiceStrategyContext.workerChoiceStrategies
+ .get(WorkerChoiceStrategies.FAIR_SHARE)
+ .workerLastVirtualTaskTimestamp.keys()) {
expect(
- pool.workerChoiceStrategyContext.workerChoiceStrategy.workerLastVirtualTaskTimestamp.get(
- workerKey
- ).start
+ pool.workerChoiceStrategyContext.workerChoiceStrategies
+ .get(WorkerChoiceStrategies.FAIR_SHARE)
+ .workerLastVirtualTaskTimestamp.get(workerKey).start
).toBe(0)
expect(
- pool.workerChoiceStrategyContext.workerChoiceStrategy.workerLastVirtualTaskTimestamp.get(
- workerKey
- ).end
+ pool.workerChoiceStrategyContext.workerChoiceStrategies
+ .get(WorkerChoiceStrategies.FAIR_SHARE)
+ .workerLastVirtualTaskTimestamp.get(workerKey).end
).toBe(0)
}
await pool.destroy()
'./tests/worker-files/thread/testWorker.js'
)
expect(
- pool.workerChoiceStrategyContext.workerChoiceStrategy
- .workerLastVirtualTaskTimestamp
+ pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
+ WorkerChoiceStrategies.FAIR_SHARE
+ )?.workerLastVirtualTaskTimestamp
).toBeUndefined()
pool.setWorkerChoiceStrategy(WorkerChoiceStrategies.FAIR_SHARE)
- for (const workerKey of pool.workerChoiceStrategyContext.workerChoiceStrategy.workerLastVirtualTaskTimestamp.keys()) {
+ for (const workerKey of pool.workerChoiceStrategyContext.workerChoiceStrategies
+ .get(WorkerChoiceStrategies.FAIR_SHARE)
+ .workerLastVirtualTaskTimestamp.keys()) {
expect(
- pool.workerChoiceStrategyContext.workerChoiceStrategy.workerLastVirtualTaskTimestamp.get(
- workerKey
- ).start
+ pool.workerChoiceStrategyContext.workerChoiceStrategies
+ .get(WorkerChoiceStrategies.FAIR_SHARE)
+ .workerLastVirtualTaskTimestamp.get(workerKey).start
).toBe(0)
expect(
- pool.workerChoiceStrategyContext.workerChoiceStrategy.workerLastVirtualTaskTimestamp.get(
- workerKey
- ).end
+ pool.workerChoiceStrategyContext.workerChoiceStrategies
+ .get(WorkerChoiceStrategies.FAIR_SHARE)
+ .workerLastVirtualTaskTimestamp.get(workerKey).end
).toBe(0)
}
// We need to clean up the resources after our test
WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN
)
expect(
- pool.workerChoiceStrategyContext.workerChoiceStrategy.currentWorkerId
+ pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
+ WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN
+ ).currentWorkerId
).toBe(0)
expect(
- pool.workerChoiceStrategyContext.workerChoiceStrategy.defaultWorkerWeight
+ pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
+ WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN
+ ).defaultWorkerWeight
).toBeGreaterThan(0)
- for (const workerKey of pool.workerChoiceStrategyContext.workerChoiceStrategy.workersTaskRunTime.keys()) {
+ for (const workerKey of pool.workerChoiceStrategyContext.workerChoiceStrategies
+ .get(WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN)
+ .workersTaskRunTime.keys()) {
expect(
- pool.workerChoiceStrategyContext.workerChoiceStrategy.workersTaskRunTime.get(
- workerKey
- ).weight
+ pool.workerChoiceStrategyContext.workerChoiceStrategies
+ .get(WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN)
+ .workersTaskRunTime.get(workerKey).weight
).toBeGreaterThan(0)
expect(
- pool.workerChoiceStrategyContext.workerChoiceStrategy.workersTaskRunTime.get(
- workerKey
- ).runTime
+ pool.workerChoiceStrategyContext.workerChoiceStrategies
+ .get(WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN)
+ .workersTaskRunTime.get(workerKey).runTime
).toBe(0)
}
// We need to clean up the resources after our test
}
await Promise.all(promises)
expect(
- pool.workerChoiceStrategyContext.workerChoiceStrategy.workersTaskRunTime
- .size
+ pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
+ WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN
+ ).workersTaskRunTime.size
).toBe(pool.workers.length)
// We need to clean up the resources after our test
await pool.destroy()
// TODO: Create a better test to cover `WeightedRoundRobinWorkerChoiceStrategy#choose`
const promises = []
const maxMultiplier =
- pool.workerChoiceStrategyContext.workerChoiceStrategy
- .defaultWorkerWeight * 2
+ pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
+ WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN
+ ).defaultWorkerWeight * 2
for (let i = 0; i < max * maxMultiplier; i++) {
promises.push(pool.execute())
}
await Promise.all(promises)
if (process.platform !== 'win32') {
expect(
- pool.workerChoiceStrategyContext.workerChoiceStrategy.workersTaskRunTime
- .size
+ pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
+ WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN
+ ).workersTaskRunTime.size
).toBe(pool.workers.length)
}
// We need to clean up the resources after our test
'./tests/worker-files/thread/testWorker.js'
)
expect(
- pool.workerChoiceStrategyContext.workerChoiceStrategy.currentWorkerId
+ pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
+ WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN
+ )?.currentWorkerId
).toBeUndefined()
expect(
- pool.workerChoiceStrategyContext.workerChoiceStrategy.defaultWorkerWeight
+ pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
+ WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN
+ )?.defaultWorkerWeight
).toBeUndefined()
expect(
- pool.workerChoiceStrategyContext.workerChoiceStrategy.workersTaskRunTime
+ pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
+ WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN
+ )?.workersTaskRunTime
).toBeUndefined()
pool.setWorkerChoiceStrategy(WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN)
expect(
- pool.workerChoiceStrategyContext.workerChoiceStrategy.currentWorkerId
+ pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
+ WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN
+ ).currentWorkerId
).toBe(0)
expect(
- pool.workerChoiceStrategyContext.workerChoiceStrategy.defaultWorkerWeight
+ pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
+ WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN
+ ).defaultWorkerWeight
).toBeGreaterThan(0)
- for (const workerKey of pool.workerChoiceStrategyContext.workerChoiceStrategy.workersTaskRunTime.keys()) {
+ for (const workerKey of pool.workerChoiceStrategyContext.workerChoiceStrategies
+ .get(WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN)
+ .workersTaskRunTime.keys()) {
expect(
- pool.workerChoiceStrategyContext.workerChoiceStrategy.workersTaskRunTime.get(
- workerKey
- ).runTime
+ pool.workerChoiceStrategyContext.workerChoiceStrategies
+ .get(WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN)
+ .workersTaskRunTime.get(workerKey).runTime
).toBe(0)
}
await pool.destroy()
'./tests/worker-files/thread/testWorker.js'
)
expect(
- pool.workerChoiceStrategyContext.workerChoiceStrategy.currentWorkerId
+ pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
+ WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN
+ )?.currentWorkerId
).toBeUndefined()
expect(
- pool.workerChoiceStrategyContext.workerChoiceStrategy.defaultWorkerWeight
+ pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
+ WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN
+ )?.defaultWorkerWeight
).toBeUndefined()
expect(
- pool.workerChoiceStrategyContext.workerChoiceStrategy.workersTaskRunTime
+ pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
+ WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN
+ )?.workersTaskRunTime
).toBeUndefined()
pool.setWorkerChoiceStrategy(WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN)
expect(
- pool.workerChoiceStrategyContext.workerChoiceStrategy.currentWorkerId
+ pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
+ WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN
+ ).currentWorkerId
).toBe(0)
expect(
- pool.workerChoiceStrategyContext.workerChoiceStrategy.defaultWorkerWeight
+ pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
+ WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN
+ ).defaultWorkerWeight
).toBeGreaterThan(0)
- for (const workerKey of pool.workerChoiceStrategyContext.workerChoiceStrategy.workersTaskRunTime.keys()) {
+ for (const workerKey of pool.workerChoiceStrategyContext.workerChoiceStrategies
+ .get(WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN)
+ .workersTaskRunTime.keys()) {
expect(
- pool.workerChoiceStrategyContext.workerChoiceStrategy.workersTaskRunTime.get(
- workerKey
- ).runTime
+ pool.workerChoiceStrategyContext.workerChoiceStrategies
+ .get(WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN)
+ .workersTaskRunTime.get(workerKey).runTime
).toBe(0)
}
// We need to clean up the resources after our test
choose: sinon.stub().returns(0)
}
)
- workerChoiceStrategyContext.workerChoiceStrategy = WorkerChoiceStrategyStub
+ expect(workerChoiceStrategyContext.workerChoiceStrategyType).toBe(
+ WorkerChoiceStrategies.ROUND_ROBIN
+ )
+ workerChoiceStrategyContext.workerChoiceStrategies.set(
+ workerChoiceStrategyContext.workerChoiceStrategyType,
+ WorkerChoiceStrategyStub
+ )
const chosenWorkerKey = workerChoiceStrategyContext.execute()
expect(
- workerChoiceStrategyContext.workerChoiceStrategy.choose.calledOnce
+ workerChoiceStrategyContext.workerChoiceStrategies.get(
+ workerChoiceStrategyContext.workerChoiceStrategyType
+ ).choose.calledOnce
).toBe(true)
expect(chosenWorkerKey).toBe(0)
})
choose: sinon.stub().returns(0)
}
)
- workerChoiceStrategyContext.workerChoiceStrategy = WorkerChoiceStrategyStub
+ expect(workerChoiceStrategyContext.workerChoiceStrategyType).toBe(
+ WorkerChoiceStrategies.ROUND_ROBIN
+ )
+ workerChoiceStrategyContext.workerChoiceStrategies.set(
+ workerChoiceStrategyContext.workerChoiceStrategyType,
+ WorkerChoiceStrategyStub
+ )
const chosenWorkerKey = workerChoiceStrategyContext.execute()
expect(
- workerChoiceStrategyContext.workerChoiceStrategy.choose.calledOnce
+ workerChoiceStrategyContext.workerChoiceStrategies.get(
+ workerChoiceStrategyContext.workerChoiceStrategyType
+ ).choose.calledOnce
).toBe(true)
expect(chosenWorkerKey).toBe(0)
})
const workerChoiceStrategyContext = new WorkerChoiceStrategyContext(
fixedPool
)
- expect(workerChoiceStrategyContext.workerChoiceStrategy).toBeInstanceOf(
- RoundRobinWorkerChoiceStrategy
- )
+ expect(
+ workerChoiceStrategyContext.workerChoiceStrategies.get(
+ WorkerChoiceStrategies.ROUND_ROBIN
+ )
+ ).toBeInstanceOf(RoundRobinWorkerChoiceStrategy)
expect(workerChoiceStrategyContext.workerChoiceStrategyType).toBe(
WorkerChoiceStrategies.ROUND_ROBIN
)
fixedPool,
WorkerChoiceStrategies.ROUND_ROBIN
)
- expect(workerChoiceStrategyContext.workerChoiceStrategy).toBeInstanceOf(
- RoundRobinWorkerChoiceStrategy
- )
+ expect(
+ workerChoiceStrategyContext.workerChoiceStrategies.get(
+ WorkerChoiceStrategies.ROUND_ROBIN
+ )
+ ).toBeInstanceOf(RoundRobinWorkerChoiceStrategy)
expect(workerChoiceStrategyContext.workerChoiceStrategyType).toBe(
WorkerChoiceStrategies.ROUND_ROBIN
)
const workerChoiceStrategyContext = new WorkerChoiceStrategyContext(
dynamicPool
)
- expect(workerChoiceStrategyContext.workerChoiceStrategy).toBeInstanceOf(
- RoundRobinWorkerChoiceStrategy
- )
+ expect(
+ workerChoiceStrategyContext.workerChoiceStrategies.get(
+ WorkerChoiceStrategies.ROUND_ROBIN
+ )
+ ).toBeInstanceOf(RoundRobinWorkerChoiceStrategy)
expect(workerChoiceStrategyContext.workerChoiceStrategyType).toBe(
WorkerChoiceStrategies.ROUND_ROBIN
)
dynamicPool,
WorkerChoiceStrategies.ROUND_ROBIN
)
- expect(workerChoiceStrategyContext.workerChoiceStrategy).toBeInstanceOf(
- RoundRobinWorkerChoiceStrategy
- )
+ expect(
+ workerChoiceStrategyContext.workerChoiceStrategies.get(
+ WorkerChoiceStrategies.ROUND_ROBIN
+ )
+ ).toBeInstanceOf(RoundRobinWorkerChoiceStrategy)
expect(workerChoiceStrategyContext.workerChoiceStrategyType).toBe(
WorkerChoiceStrategies.ROUND_ROBIN
)
fixedPool,
WorkerChoiceStrategies.LESS_USED
)
- expect(workerChoiceStrategyContext.workerChoiceStrategy).toBeInstanceOf(
- LessUsedWorkerChoiceStrategy
- )
+ expect(
+ workerChoiceStrategyContext.workerChoiceStrategies.get(
+ WorkerChoiceStrategies.LESS_USED
+ )
+ ).toBeInstanceOf(LessUsedWorkerChoiceStrategy)
expect(workerChoiceStrategyContext.workerChoiceStrategyType).toBe(
WorkerChoiceStrategies.LESS_USED
)
dynamicPool,
WorkerChoiceStrategies.LESS_USED
)
- expect(workerChoiceStrategyContext.workerChoiceStrategy).toBeInstanceOf(
- LessUsedWorkerChoiceStrategy
- )
+ expect(
+ workerChoiceStrategyContext.workerChoiceStrategies.get(
+ WorkerChoiceStrategies.LESS_USED
+ )
+ ).toBeInstanceOf(LessUsedWorkerChoiceStrategy)
expect(workerChoiceStrategyContext.workerChoiceStrategyType).toBe(
WorkerChoiceStrategies.LESS_USED
)
fixedPool,
WorkerChoiceStrategies.LESS_BUSY
)
- expect(workerChoiceStrategyContext.workerChoiceStrategy).toBeInstanceOf(
- LessBusyWorkerChoiceStrategy
- )
+ expect(
+ workerChoiceStrategyContext.workerChoiceStrategies.get(
+ WorkerChoiceStrategies.LESS_BUSY
+ )
+ ).toBeInstanceOf(LessBusyWorkerChoiceStrategy)
expect(workerChoiceStrategyContext.workerChoiceStrategyType).toBe(
WorkerChoiceStrategies.LESS_BUSY
)
dynamicPool,
WorkerChoiceStrategies.LESS_BUSY
)
- expect(workerChoiceStrategyContext.workerChoiceStrategy).toBeInstanceOf(
- LessBusyWorkerChoiceStrategy
- )
+ expect(
+ workerChoiceStrategyContext.workerChoiceStrategies.get(
+ WorkerChoiceStrategies.LESS_BUSY
+ )
+ ).toBeInstanceOf(LessBusyWorkerChoiceStrategy)
expect(workerChoiceStrategyContext.workerChoiceStrategyType).toBe(
WorkerChoiceStrategies.LESS_BUSY
)
fixedPool,
WorkerChoiceStrategies.FAIR_SHARE
)
- expect(workerChoiceStrategyContext.workerChoiceStrategy).toBeInstanceOf(
- FairShareWorkerChoiceStrategy
- )
+ expect(
+ workerChoiceStrategyContext.workerChoiceStrategies.get(
+ WorkerChoiceStrategies.FAIR_SHARE
+ )
+ ).toBeInstanceOf(FairShareWorkerChoiceStrategy)
expect(workerChoiceStrategyContext.workerChoiceStrategyType).toBe(
WorkerChoiceStrategies.FAIR_SHARE
)
dynamicPool,
WorkerChoiceStrategies.FAIR_SHARE
)
- expect(workerChoiceStrategyContext.workerChoiceStrategy).toBeInstanceOf(
- FairShareWorkerChoiceStrategy
- )
+ expect(
+ workerChoiceStrategyContext.workerChoiceStrategies.get(
+ WorkerChoiceStrategies.FAIR_SHARE
+ )
+ ).toBeInstanceOf(FairShareWorkerChoiceStrategy)
expect(workerChoiceStrategyContext.workerChoiceStrategyType).toBe(
WorkerChoiceStrategies.FAIR_SHARE
)
fixedPool,
WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN
)
- expect(workerChoiceStrategyContext.workerChoiceStrategy).toBeInstanceOf(
- WeightedRoundRobinWorkerChoiceStrategy
- )
+ expect(
+ workerChoiceStrategyContext.workerChoiceStrategies.get(
+ WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN
+ )
+ ).toBeInstanceOf(WeightedRoundRobinWorkerChoiceStrategy)
expect(workerChoiceStrategyContext.workerChoiceStrategyType).toBe(
WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN
)
dynamicPool,
WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN
)
- expect(workerChoiceStrategyContext.workerChoiceStrategy).toBeInstanceOf(
- WeightedRoundRobinWorkerChoiceStrategy
- )
+ expect(
+ workerChoiceStrategyContext.workerChoiceStrategies.get(
+ WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN
+ )
+ ).toBeInstanceOf(WeightedRoundRobinWorkerChoiceStrategy)
expect(workerChoiceStrategyContext.workerChoiceStrategyType).toBe(
WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN
)