/// <summary> /// Register a named entity type by defining the <see cref="Actor.Props"/> of the entity actor and /// functions to extract entity and shard identifier from messages. The <see cref="Sharding.ShardRegion"/> /// actor for this type can later be retrieved with the <see cref="ShardRegion"/> method. /// </summary> /// <param name="typeName">The name of the entity type</param> /// <param name="entityProps"> /// The <see cref="Actor.Props"/> of the entity actors that will be created by the <see cref="Sharding.ShardRegion"/> /// </param> /// <param name="settings">Configuration settings, see <see cref="ClusterShardingSettings"/></param> /// <param name="idExtractor"> /// Partial function to extract the entity id and the message to send to the entity from the incoming message, /// if the partial function does not match the message will be `unhandled`, /// i.e.posted as `Unhandled` messages on the event stream /// </param> /// <param name="shardResolver"> /// Function to determine the shard id for an incoming message, only messages that passed the `extractEntityId` will be used /// </param> /// <returns>The actor ref of the <see cref="Sharding.ShardRegion"/> that is to be responsible for the shard.</returns> public Task <IActorRef> StartAsync( string typeName, //TODO: change type name to type instance? Props entityProps, ClusterShardingSettings settings, IdExtractor idExtractor, ShardResolver shardResolver) { var allocationStrategy = new LeastShardAllocationStrategy( Settings.TunningParameters.LeastShardAllocationRebalanceThreshold, Settings.TunningParameters.LeastShardAllocationMaxSimultaneousRebalance); return(StartAsync(typeName, entityProps, settings, idExtractor, shardResolver, allocationStrategy, PoisonPill.Instance)); }
/// <summary> /// Register a named entity type by defining the <see cref="Actor.Props"/> of the entity actor and /// functions to extract entity and shard identifier from messages. The <see cref="Sharding.ShardRegion"/> /// actor for this type can later be retrieved with the <see cref="ShardRegion"/> method. /// </summary> /// <param name="typeName">The name of the entity type</param> /// <param name="entityProps"> /// The <see cref="Actor.Props"/> of the entity actors that will be created by the <see cref="Sharding.ShardRegion"/> /// </param> /// <param name="settings">Configuration settings, see <see cref="ClusterShardingSettings"/></param> /// <param name="extractEntityId"> /// Partial function to extract the entity id and the message to send to the entity from the incoming message, /// if the partial function does not match the message will be `unhandled`, /// i.e.posted as `Unhandled` messages on the event stream /// </param> /// <param name="extractShardId"> /// Function to determine the shard id for an incoming message, only messages that passed the `extractEntityId` will be used /// </param> /// <returns>The actor ref of the <see cref="Sharding.ShardRegion"/> that is to be responsible for the shard.</returns> public Task <IActorRef> StartAsync( string typeName, Props entityProps, ClusterShardingSettings settings, ExtractEntityId extractEntityId, ExtractShardId extractShardId) { var allocationStrategy = new LeastShardAllocationStrategy( Settings.TunningParameters.LeastShardAllocationRebalanceThreshold, Settings.TunningParameters.LeastShardAllocationMaxSimultaneousRebalance); return(StartAsync(typeName, entityProps, settings, extractEntityId, extractShardId, allocationStrategy, PoisonPill.Instance)); }