- /** {@inheritDoc} */
- public choose (): Worker {
- const chosenWorker = this.pool.workers[this.currentWorkerIndex]
- if (this.isDynamicPool && !this.workersTaskRunTime.has(chosenWorker)) {
- this.initWorkerTaskRunTime(chosenWorker)
- }
- const workerTaskRunTime =
- this.workersTaskRunTime.get(chosenWorker)?.runTime ?? 0
- const workerTaskWeight =
- this.workersTaskRunTime.get(chosenWorker)?.weight ??
- this.defaultWorkerWeight
- if (workerTaskRunTime < workerTaskWeight) {
- this.setWorkerTaskRunTime(
- chosenWorker,
- workerTaskWeight,
- workerTaskRunTime +
- (this.getWorkerVirtualTaskRunTime(chosenWorker) ?? 0)
- )
+ /** @inheritDoc */
+ public update (): boolean {
+ return true
+ }
+
+ /** @inheritDoc */
+ public choose (): number {
+ const chosenWorkerNodeKey = this.currentWorkerNodeId
+ const workerVirtualTaskRunTime = this.workerVirtualTaskRunTime
+ const workerWeight =
+ this.opts.weights?.[chosenWorkerNodeKey] ?? this.defaultWorkerWeight
+ if (workerVirtualTaskRunTime < workerWeight) {
+ this.workerVirtualTaskRunTime =
+ workerVirtualTaskRunTime +
+ this.getWorkerTaskRunTime(chosenWorkerNodeKey)