- public choose (): number {
- const chosenWorkerNodeKey = this.currentWorkerNodeId
- const workerTaskRunTime = this.workerVirtualTaskRunTime ?? 0
- const workerTaskWeight =
- this.opts.weights?.[chosenWorkerNodeKey] ?? this.defaultWorkerWeight
- if (workerTaskRunTime < workerTaskWeight) {
- this.workerVirtualTaskRunTime =
- workerTaskRunTime +
- (this.getWorkerVirtualTaskRunTime(chosenWorkerNodeKey) ?? 0)
- } else {
- this.currentWorkerNodeId =
- this.currentWorkerNodeId === this.pool.workerNodes.length - 1
- ? 0
- : this.currentWorkerNodeId + 1
- this.workerVirtualTaskRunTime = 0
- }
- return chosenWorkerNodeKey
+ public update (): boolean {
+ return true
+ }
+
+ /** @inheritDoc */
+ public choose (): number | undefined {
+ this.setPreviousWorkerNodeKey(this.nextWorkerNodeKey)
+ return this.weightedRoundRobinNextWorkerNodeKey()