1 import type { IPoolInternal
} from
'../pool-internal'
2 import { PoolType
} from
'../pool-internal'
3 import type { IWorker
} from
'../worker'
7 } from
'./selection-strategies-types'
10 * Worker choice strategy abstract base class.
12 * @typeParam Worker - Type of worker which manages the strategy.
13 * @typeParam Data - Type of data sent to the worker. This can only be serializable data.
14 * @typeParam Response - Type of response of execution. This can only be serializable data.
16 export abstract class AbstractWorkerChoiceStrategy
<
17 Worker
extends IWorker
,
20 > implements IWorkerChoiceStrategy
{
22 protected readonly isDynamicPool
: boolean
24 public requiredStatistics
: RequiredStatistics
= {
31 * Constructs a worker choice strategy bound to the pool.
33 * @param pool - The pool instance.
36 protected readonly pool
: IPoolInternal
<Worker
, Data
, Response
>
38 this.isDynamicPool
= this.pool
.type === PoolType
.DYNAMIC
39 this.choose
.bind(this)
43 public abstract reset (): boolean
46 public abstract choose (): number
49 public abstract remove (workerNodeKey
: number): boolean