AllocationStrategy
Defined in: src/cluster/sharding/AllocationStrategy.ts:10
Instructs the ShardCoordinator how to place and rebalance shards.
allocate is called when a shard needs a new home — e.g. right after it
is first requested. rebalance is called periodically so strategies can
move shards away from busy nodes.
Methods
Section titled “Methods”allocate()
Section titled “allocate()”allocate(
shardId,candidates,currentShards):NodeAddress
Defined in: src/cluster/sharding/AllocationStrategy.ts:12
Pick an owner for a newly-discovered shard.
Parameters
Section titled “Parameters”shardId
Section titled “shardId”number
candidates
Section titled “candidates”readonly NodeAddress[]
currentShards
Section titled “currentShards”ReadonlyMap<string, ReadonlySet<number>>
Returns
Section titled “Returns”rebalance()
Section titled “rebalance()”rebalance(
currentShards,candidates,rebalanceInProgress):Set<number>
Defined in: src/cluster/sharding/AllocationStrategy.ts:19
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>