Skip to content

Commit ffd9a9e

Browse files
close #6295 - set default PoolRouter SupervisorStrategy to Restart (#6366)
* close #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>
1 parent 579741d commit ffd9a9e

File tree

2 files changed

+13
-25
lines changed

2 files changed

+13
-25
lines changed

src/core/Akka.Tests/Routing/RoutingSpec.cs

+11-17
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
using System.Linq;
1212
using Akka.Configuration;
1313
using Akka.Actor;
14+
using Akka.Actor.Dsl;
1415
using Akka.Dispatch;
1516
using Akka.Routing;
1617
using Akka.TestKit;
@@ -293,27 +294,20 @@ public void Routers_in_general_must_set_supplied_supervisorStrategy_for_FromConf
293294
}
294295

295296
[Fact]
296-
public void Routers_in_general_must_default_to_all_for_one_always_escalate_strategy()
297+
public void Routers_in_general_must_default_to_all_for_one_restart_strategy()
297298
{
298-
var restarter = new OneForOneStrategy(e =>
299-
{
300-
TestActor.Tell(e);
301-
return Directive.Restart;
302-
});
303-
304-
var supervisor = Sys.ActorOf(Props.Create(() => new Supervisor(restarter)));
299+
var router = Sys.ActorOf(new RoundRobinPool(3).Props(Props.Create(() => new RestartActor(TestActor))));
300+
var restarted = new HashSet<string>();
305301

306-
supervisor.Tell(new RoundRobinPool(3).Props(Props.Create(() => new RestartActor(TestActor))));
307-
308-
var router = ExpectMsg<IActorRef>();
309-
EventFilter.Exception<ArgumentException>("die").ExpectOne(() =>
302+
for (var i = 0; i < 3; i++)
310303
{
311304
router.Tell("die");
312-
});
313-
ExpectMsg<ArgumentException>().Message.Should().Be("die");
314-
ExpectMsg("restarted");
315-
ExpectMsg("restarted");
316-
ExpectMsg("restarted");
305+
ExpectMsg("restarted");
306+
restarted.Add(LastSender.Path.Name);
307+
}
308+
309+
restarted.Count.Should().Be(3);
310+
restarted.Should().BeEquivalentTo(((RoutedActorRef)router).Children.Select(c => c.Path.Name));
317311
}
318312

319313
[Fact]

src/core/Akka/Routing/RouterConfig.cs

+2-8
Original file line numberDiff line numberDiff line change
@@ -354,15 +354,9 @@ public override ActorBase CreateRouterActor()
354354
/// <summary>
355355
/// TBD
356356
/// </summary>
357-
public static SupervisorStrategy DefaultSupervisorStrategy
358-
{
359-
get
360-
{
361-
return new OneForOneStrategy(Decider.From(Directive.Escalate));
362-
}
363-
}
357+
public static SupervisorStrategy DefaultSupervisorStrategy => SupervisorStrategy.DefaultStrategy;
358+
364359

365-
366360
public bool Equals(Pool other)
367361
{
368362
if (ReferenceEquals(null, other)) return false;

0 commit comments

Comments
 (0)