Skip to content

Commit

Permalink
close akkadotnet#6295 - set default PoolRouter SupervisorStrategy to …
Browse files Browse the repository at this point in the history
…Restart (akkadotnet#6366)

* close akkadotnet#6295 - set default PoolRouter SupervisorStrategy to Restart

* use the `SupervisionStrategy.DefaultStrategy`

* Fix unit test

* Change unit test to use RoundRobinPool router

Co-authored-by: Gregorius Soedharmo <arkatufus@yahoo.com>
  • Loading branch information
Aaronontheweb and Arkatufus committed Jan 26, 2023
1 parent 579741d commit ffd9a9e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 25 deletions.
28 changes: 11 additions & 17 deletions src/core/Akka.Tests/Routing/RoutingSpec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using System.Linq;
using Akka.Configuration;
using Akka.Actor;
using Akka.Actor.Dsl;
using Akka.Dispatch;
using Akka.Routing;
using Akka.TestKit;
Expand Down Expand Up @@ -293,27 +294,20 @@ public void Routers_in_general_must_set_supplied_supervisorStrategy_for_FromConf
}

[Fact]
public void Routers_in_general_must_default_to_all_for_one_always_escalate_strategy()
public void Routers_in_general_must_default_to_all_for_one_restart_strategy()
{
var restarter = new OneForOneStrategy(e =>
{
TestActor.Tell(e);
return Directive.Restart;
});

var supervisor = Sys.ActorOf(Props.Create(() => new Supervisor(restarter)));
var router = Sys.ActorOf(new RoundRobinPool(3).Props(Props.Create(() => new RestartActor(TestActor))));
var restarted = new HashSet<string>();

supervisor.Tell(new RoundRobinPool(3).Props(Props.Create(() => new RestartActor(TestActor))));

var router = ExpectMsg<IActorRef>();
EventFilter.Exception<ArgumentException>("die").ExpectOne(() =>
for (var i = 0; i < 3; i++)
{
router.Tell("die");
});
ExpectMsg<ArgumentException>().Message.Should().Be("die");
ExpectMsg("restarted");
ExpectMsg("restarted");
ExpectMsg("restarted");
ExpectMsg("restarted");
restarted.Add(LastSender.Path.Name);
}

restarted.Count.Should().Be(3);
restarted.Should().BeEquivalentTo(((RoutedActorRef)router).Children.Select(c => c.Path.Name));
}

[Fact]
Expand Down
10 changes: 2 additions & 8 deletions src/core/Akka/Routing/RouterConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -354,15 +354,9 @@ public override ActorBase CreateRouterActor()
/// <summary>
/// TBD
/// </summary>
public static SupervisorStrategy DefaultSupervisorStrategy
{
get
{
return new OneForOneStrategy(Decider.From(Directive.Escalate));
}
}
public static SupervisorStrategy DefaultSupervisorStrategy => SupervisorStrategy.DefaultStrategy;



public bool Equals(Pool other)
{
if (ReferenceEquals(null, other)) return false;
Expand Down

0 comments on commit ffd9a9e

Please sign in to comment.