public void When_creating_actors_in_system_Then_they_should_be_created_in_UserGuardian() { var system = new ActorSys(); system.Start(); system.CreateActor(ActorCreationProperties.Create <TestActor>(), "Actor1"); system.CreateActor(ActorCreationProperties.Create <TestActor>(), "Actor2"); system.CreateActor(ActorCreationProperties.Create <TestActor>(), "Actor3"); system.Children.Should().ContainInOrder(new object[] { "Actor1", "Actor2", "Actor3" }); }
public void ClusterSingletonProxy_must_correctly_identify_the_singleton() { var seed = new ActorSys(); seed.Cluster.Join(seed.Cluster.SelfAddress); var testSystems = Enumerable.Range(0, 4).Select(x => new ActorSys(joinTo: seed.Cluster.SelfAddress)) .Concat(new[] { seed }) .ToList(); try { testSystems.ForEach(s => s.TestProxy("Hello")); testSystems.ForEach(s => s.TestProxy("World")); } finally { // force everything to cleanup Task.WhenAll(testSystems.Select(s => s.Sys.Terminate())) .Wait(TimeSpan.FromSeconds(30)); } }
public async Task ClusterSingletonProxy_with_zero_buffering_should_work() { var seed = new ActorSys(); seed.Cluster.Join(seed.Cluster.SelfAddress); var testSystem = new ActorSys(joinTo: seed.Cluster.SelfAddress, bufferSize: 0); // have to wait for cluster singleton to be ready, otherwise message will be rejected await AwaitConditionAsync( () => Cluster.Get(testSystem.Sys).State.Members.Count(m => m.Status == MemberStatus.Up) == 2, TimeSpan.FromSeconds(30)); try { testSystem.TestProxy("Hello"); } finally { // force everything to cleanup Task.WhenAll(testSystem.Sys.Terminate()).Wait(TimeSpan.FromSeconds(30)); } }
public Task StopAsync(CancellationToken cancellationToken) { return(ActorSys.Terminate().ContinueWith(_ => Console.WriteLine($"[{DateTime.Now}] ActorSys terminated!"), cancellationToken)); // return CoordinatedShutdown.Get(ActorSys).Run(CoordinatedShutdown.ActorSystemTerminateReason.Instance); }