HashAllocationStrategy
Defined in: src/cluster/sharding/AllocationStrategy.ts:33
Hash-based: allocate by modulo on the sorted candidate list. Simple, deterministic, minimal rebalance behaviour (only moves shards when the candidate set changes).
Implements
Section titled “Implements”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new HashAllocationStrategy():
HashAllocationStrategy
Returns
Section titled “Returns”HashAllocationStrategy
Methods
Section titled “Methods”allocate()
Section titled “allocate()”allocate(
shardId,candidates):NodeAddress
Defined in: src/cluster/sharding/AllocationStrategy.ts:34
Pick an owner for a newly-discovered shard.
Parameters
Section titled “Parameters”shardId
Section titled “shardId”number
candidates
Section titled “candidates”readonly NodeAddress[]
Returns
Section titled “Returns”Implementation of
Section titled “Implementation of”rebalance()
Section titled “rebalance()”rebalance(
currentShards,candidates,rebalanceInProgress):Set<number>
Defined in: src/cluster/sharding/AllocationStrategy.ts:40
Return a set of shard ids that should be re-homed. The coordinator will send HandOff for each and then allocate() a new home once the handoff completes.
Parameters
Section titled “Parameters”currentShards
Section titled “currentShards”ReadonlyMap<string, ReadonlySet<number>>
candidates
Section titled “candidates”readonly NodeAddress[]
rebalanceInProgress
Section titled “rebalanceInProgress”ReadonlySet<number>
Returns
Section titled “Returns”Set<number>