* Selects the least used worker.
*
* @typeParam Worker - Type of worker which manages the strategy.
- * @typeParam Data - Type of data sent to the worker. This can only be serializable data.
- * @typeParam Response - Type of execution response. This can only be serializable data.
+ * @typeParam Data - Type of data sent to the worker. This can only be structured-cloneable data.
+ * @typeParam Response - Type of execution response. This can only be structured-cloneable data.
*/
export class LeastUsedWorkerChoiceStrategy<
Worker extends IWorker,
/** @inheritDoc */
public update (): boolean {
+ return true
+ }
+
+ /** @inheritDoc */
+ public choose (): number {
let minNumberOfTasks = Infinity
for (const [workerNodeKey, workerNode] of this.pool.workerNodes.entries()) {
- const workerTaskStatistics = workerNode.workerUsage.tasks
+ const workerTaskStatistics = workerNode.usage.tasks
const workerTasks =
workerTaskStatistics.executed +
workerTaskStatistics.executing +
this.nextWorkerNodeId = workerNodeKey
}
}
- return true
- }
-
- /** @inheritDoc */
- public choose (): number {
return this.nextWorkerNodeId
}