public void ProxyShardingSpec_Shard_region_should_be_found() { var shardRegion = clusterSharding.Start("myType", EchoActor.Props(this), shardingSettings, messageExtractor); shardRegion.Path.Should().NotBeNull(); shardRegion.Path.ToString().Should().EndWith("myType"); }
public Chat() { Context.Become(UnInitialized); RecoverAny(UpdateState); ClusterSharding clusterSharding = ClusterSharding.Get(Context.System); _userRegion = clusterSharding.ShardRegion(typeof(User).Name); _chatView = Context.ActorOf(Props.Create(() => new ChatView())); if (_userRegion == null) { _userRegion = clusterSharding.Start( typeName: typeof(User).Name, entityProps: Props.Create <User>(), settings: ClusterShardingSettings.Create(Context.System), messageExtractor: new MessageExtractor(10)); } }
public void ClusterSharding_must_start_a_region_in_proxy_mode_in_case_of_node_role_mismatch() { var settingsWithRole = ClusterShardingSettings.Create(Sys).WithRole("nonExistingRole"); var typeName = "typeName"; var region = clusterSharding.Start( typeName: typeName, entityProps: Props.Empty, settings: settingsWithRole, extractEntityId: ExtractEntityId, extractShardId: ExtractShardId, allocationStrategy: new LeastShardAllocationStrategy(0, 0), handOffStopMessage: PoisonPill.Instance); var proxy = clusterSharding.StartProxy( typeName: typeName, role: settingsWithRole.Role, extractEntityId: ExtractEntityId, extractShardId: ExtractShardId ); region.Should().BeSameAs(proxy); }
public User() { Context.Become(Unregistered); RecoverAny(UpdateState); Guid userId = Guid.Parse(Self.Path.Name); _userView = Context.ActorOf(Props.Create(() => new UserView())); _userContactsView = Context.ActorOf(Props.Create(() => new UserContactsView())); _userChatView = Context.ActorOf(Props.Create(() => new UserChatView(userId))); _userBadgeView = Context.ActorOf(Props.Create(() => new UserBadgeView(userId))); ClusterSharding clusterSharding = ClusterSharding.Get(Context.System); _region = clusterSharding.ShardRegion(typeof(User).Name); if (_region == null) { _region = clusterSharding.Start( typeName: typeof(User).Name, entityProps: Props.Create <User>(), settings: ClusterShardingSettings.Create(Context.System), messageExtractor: new MessageExtractor(10)); } }