Interface IShardAllocationStrategy
Interface of the pluggable shard allocation and rebalancing logic used by the Akka.Cluster.Sharding.PersistentShardCoordinator.
Namespace: Akka.Cluster.Sharding
Assembly: Akka.Cluster.Sharding.dll
Syntax
public interface IShardAllocationStrategy : INoSerializationVerificationNeeded
Methods
| Improve this Doc View SourceAllocateShard(IActorRef, String, IImmutableDictionary<IActorRef, IImmutableList<String>>)
Invoked when the location of a new shard is to be decided.
Declaration
Task<IActorRef> AllocateShard(IActorRef requester, string shardId, IImmutableDictionary<IActorRef, IImmutableList<string>> currentShardAllocations)
Parameters
Type | Name | Description |
---|---|---|
IActorRef | requester | Actor reference to the ShardRegion that requested the location of the shard, can be returned if preference should be given to the node where the shard was first accessed. |
String | shardId | The id of the shard to allocate. |
System.Collections.Immutable.IImmutableDictionary<IActorRef, System.Collections.Immutable.IImmutableList<String>> | currentShardAllocations | All actor refs to ShardRegion and their current allocated shards, in the order they were allocated |
Returns
Type | Description |
---|---|
Task<IActorRef> | Task of the actor ref of the ShardRegion that is to be responsible for the shard,
must be one of the references included in the |
Rebalance(IImmutableDictionary<IActorRef, IImmutableList<String>>, IImmutableSet<String>)
Invoked periodically to decide which shards to rebalance to another location.
Declaration
Task<IImmutableSet<string>> Rebalance(IImmutableDictionary<IActorRef, IImmutableList<string>> currentShardAllocations, IImmutableSet<string> rebalanceInProgress)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Immutable.IImmutableDictionary<IActorRef, System.Collections.Immutable.IImmutableList<String>> | currentShardAllocations | All actor refs to ShardRegion and their current allocated shards, in the order they were allocated. |
System.Collections.Immutable.IImmutableSet<String> | rebalanceInProgress | Set of shards that are currently being rebalanced, i.e. you should not include these in the returned set. |
Returns
Type | Description |
---|---|
Task<System.Collections.Immutable.IImmutableSet<String>> | Task of the shards to be migrated, may be empty to skip rebalance in this round. |