Skip to content

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).

new HashAllocationStrategy(): HashAllocationStrategy

HashAllocationStrategy

allocate(shardId, candidates): NodeAddress

Defined in: src/cluster/sharding/AllocationStrategy.ts:34

Pick an owner for a newly-discovered shard.

number

readonly NodeAddress[]

NodeAddress

AllocationStrategy.allocate


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.

ReadonlyMap<string, ReadonlySet<number>>

readonly NodeAddress[]

ReadonlySet<number>

Set<number>

AllocationStrategy.rebalance