diff --git a/src/core/Akka.API.Tests/CoreAPISpec.ApproveCore.approved.txt b/src/core/Akka.API.Tests/CoreAPISpec.ApproveCore.approved.txt index 47453b7bc88..c23a80dddb0 100644 --- a/src/core/Akka.API.Tests/CoreAPISpec.ApproveCore.approved.txt +++ b/src/core/Akka.API.Tests/CoreAPISpec.ApproveCore.approved.txt @@ -4061,7 +4061,9 @@ namespace Akka.Routing } public abstract class Group : Akka.Routing.RouterConfig, System.IEquatable { + protected readonly string[] InternalPaths; protected Group(System.Collections.Generic.IEnumerable paths, string routerDispatcher) { } + [System.ObsoleteAttribute("Deprecated since Akka.NET v1.1. Use Paths(ActorSystem) instead.")] public System.Collections.Generic.IEnumerable Paths { get; } public bool Equals(Akka.Routing.Group other) { } public override bool Equals(object obj) { } diff --git a/src/core/Akka.Cluster.Tests.MultiNode/Routing/UseRoleIgnoredSpec.cs b/src/core/Akka.Cluster.Tests.MultiNode/Routing/UseRoleIgnoredSpec.cs index 8584f9fc910..245f2cdf3d6 100644 --- a/src/core/Akka.Cluster.Tests.MultiNode/Routing/UseRoleIgnoredSpec.cs +++ b/src/core/Akka.Cluster.Tests.MultiNode/Routing/UseRoleIgnoredSpec.cs @@ -272,7 +272,7 @@ private void A_cluster_must_group_local_on_role_b() var router = Sys.ActorOf( new ClusterRouterGroup( new RoundRobinGroup(paths: null), - new ClusterRouterGroupSettings(6, ImmutableHashSet.Create("/user/foo", "/user/bar"), allowLocalRoutees: false, useRole: role)).Props(), + new ClusterRouterGroupSettings(6, ImmutableHashSet.Create("/user/foo", "/user/bar"), allowLocalRoutees: true, useRole: role)).Props(), "router-3b"); AwaitAssert(() => CurrentRoutees(router).Count().Should().Be(4)); diff --git a/src/core/Akka.Cluster.Tests/ClusterDeployerSpec.cs b/src/core/Akka.Cluster.Tests/ClusterDeployerSpec.cs index 9996082bbbd..7fe8059ad89 100644 --- a/src/core/Akka.Cluster.Tests/ClusterDeployerSpec.cs +++ b/src/core/Akka.Cluster.Tests/ClusterDeployerSpec.cs @@ -84,7 +84,7 @@ public void RemoteDeployer_must_be_able_to_parse_akka_actor_deployment_with_spec deployment.Path.ShouldBe(service); deployment.RouterConfig.GetType().ShouldBe(typeof(ClusterRouterGroup)); deployment.RouterConfig.AsInstanceOf().Local.GetType().ShouldBe(typeof(RoundRobinGroup)); - deployment.RouterConfig.AsInstanceOf().Local.AsInstanceOf().Paths.ShouldBe(new[]{ "/user/myservice" }); + deployment.RouterConfig.AsInstanceOf().Local.AsInstanceOf().GetPaths(Sys).ShouldBe(new[]{ "/user/myservice" }); deployment.RouterConfig.AsInstanceOf().Settings.TotalInstances.ShouldBe(20); deployment.RouterConfig.AsInstanceOf().Settings.AllowLocalRoutees.ShouldBe(false); deployment.RouterConfig.AsInstanceOf().Settings.UseRole.ShouldBe("backend"); @@ -104,7 +104,7 @@ public void BugFix2266RemoteDeployer_must_be_able_to_parse_broadcast_group_clust deployment.Path.ShouldBe(service); deployment.RouterConfig.GetType().ShouldBe(typeof(ClusterRouterGroup)); deployment.RouterConfig.AsInstanceOf().Local.GetType().ShouldBe(typeof(BroadcastGroup)); - deployment.RouterConfig.AsInstanceOf().Local.AsInstanceOf().Paths.ShouldBe(new[] { "/user/myservice" }); + deployment.RouterConfig.AsInstanceOf().Local.AsInstanceOf().GetPaths(Sys).ShouldBe(new[] { "/user/myservice" }); deployment.RouterConfig.AsInstanceOf().Settings.TotalInstances.ShouldBe(10000); deployment.RouterConfig.AsInstanceOf().Settings.AllowLocalRoutees.ShouldBe(false); deployment.RouterConfig.AsInstanceOf().Settings.UseRole.ShouldBe("backend"); diff --git a/src/core/Akka.Cluster/Routing/ClusterRoutingConfig.cs b/src/core/Akka.Cluster/Routing/ClusterRoutingConfig.cs index 34bcfc5042b..fe7e6fba533 100644 --- a/src/core/Akka.Cluster/Routing/ClusterRoutingConfig.cs +++ b/src/core/Akka.Cluster/Routing/ClusterRoutingConfig.cs @@ -52,10 +52,12 @@ public ClusterRouterGroupSettings(int totalInstances, bool allowLocalRoutees, st /// /// Initializes a new instance of the class. /// - /// TBD - /// TBD - /// TBD - /// TBD + /// The total number of routees. Defaults to 10000. + /// The actor selection paths to use for each routee. + /// When true, allows routees to be deployed locally + /// on the node doing the deploying so long as that node also + /// satisfies the useRole setting when used. + /// The role of the node upon which we are able to create routees. /// /// This exception is thrown when either the specified is undefined /// or a path defined in the specified is an invalid relative actor path. @@ -79,7 +81,7 @@ public ClusterRouterGroupSettings(int totalInstances, IEnumerable routee } /// - /// TBD + /// The paths of the routees to use on each qualified node. /// public IEnumerable RouteesPaths { get; } @@ -150,7 +152,7 @@ public ClusterRouterPoolSettings(int totalInstances, int maxInstancesPerNode, bo } /// - /// TBD + /// The maximum number of routee actors that can be deployed per valid node. /// public int MaxInstancesPerNode { get; } diff --git a/src/core/Akka.Tests/Routing/ConfiguredLocalRoutingSpec.cs b/src/core/Akka.Tests/Routing/ConfiguredLocalRoutingSpec.cs index 07d587b8cac..d20b2d9612e 100644 --- a/src/core/Akka.Tests/Routing/ConfiguredLocalRoutingSpec.cs +++ b/src/core/Akka.Tests/Routing/ConfiguredLocalRoutingSpec.cs @@ -234,7 +234,7 @@ public async Task RouterConfig_must_use_routeesPaths_from_config() routerConfig.Should().BeOfType(); var randomGroup = (RandomGroup)routerConfig; - randomGroup.Paths.ShouldAllBeEquivalentTo(new List { "/user/service1", "/user/service2" }); + randomGroup.GetPaths(Sys).ShouldAllBeEquivalentTo(new List { "/user/service1", "/user/service2" }); var result = await actor.GracefulStop(3.Seconds()); result.Should().BeTrue(); diff --git a/src/core/Akka/Routing/Broadcast.cs b/src/core/Akka/Routing/Broadcast.cs index 7e3c675931c..fbc09bfc086 100644 --- a/src/core/Akka/Routing/Broadcast.cs +++ b/src/core/Akka/Routing/Broadcast.cs @@ -301,7 +301,7 @@ public BroadcastGroup(IEnumerable paths, string routerDispatcher) : base /// An enumeration of actor paths used during routee selection public override IEnumerable GetPaths(ActorSystem system) { - return Paths; + return InternalPaths; } /// @@ -325,7 +325,7 @@ public override Router CreateRouter(ActorSystem system) /// A new router with the provided dispatcher id. public Group WithDispatcher(string dispatcher) { - return new BroadcastGroup(Paths, dispatcher); + return new BroadcastGroup(InternalPaths, dispatcher); } /// @@ -337,7 +337,7 @@ public override ISurrogate ToSurrogate(ActorSystem system) { return new BroadcastGroupSurrogate { - Paths = Paths, + Paths = InternalPaths, RouterDispatcher = RouterDispatcher }; } diff --git a/src/core/Akka/Routing/ConsistentHashRouter.cs b/src/core/Akka/Routing/ConsistentHashRouter.cs index f5e73437cdc..c0ff513252a 100644 --- a/src/core/Akka/Routing/ConsistentHashRouter.cs +++ b/src/core/Akka/Routing/ConsistentHashRouter.cs @@ -696,7 +696,7 @@ public ConsistentHashingGroup( /// An enumeration of actor paths used during routee selection public override IEnumerable GetPaths(ActorSystem system) { - return Paths; + return InternalPaths; } /// @@ -722,7 +722,7 @@ public override Router CreateRouter(ActorSystem system) /// A new router with the provided dispatcher id. public ConsistentHashingGroup WithDispatcher(string dispatcher) { - return new ConsistentHashingGroup(Paths, VirtualNodesFactor, _hashMapping, dispatcher); + return new ConsistentHashingGroup(InternalPaths, VirtualNodesFactor, _hashMapping, dispatcher); } /// @@ -736,7 +736,7 @@ public ConsistentHashingGroup WithDispatcher(string dispatcher) /// A new router with the provided . public ConsistentHashingGroup WithVirtualNodesFactor(int vnodes) { - return new ConsistentHashingGroup(Paths, vnodes, _hashMapping, RouterDispatcher); + return new ConsistentHashingGroup(InternalPaths, vnodes, _hashMapping, RouterDispatcher); } /// @@ -750,7 +750,7 @@ public ConsistentHashingGroup WithVirtualNodesFactor(int vnodes) /// A new router with the provided . public ConsistentHashingGroup WithHashMapping(ConsistentHashMapping mapping) { - return new ConsistentHashingGroup(Paths, VirtualNodesFactor, mapping, RouterDispatcher); + return new ConsistentHashingGroup(InternalPaths, VirtualNodesFactor, mapping, RouterDispatcher); } /// @@ -786,7 +786,7 @@ public override ISurrogate ToSurrogate(ActorSystem system) { return new ConsistentHashingGroupSurrogate { - Paths = Paths, + Paths = InternalPaths, RouterDispatcher = RouterDispatcher }; } diff --git a/src/core/Akka/Routing/Random.cs b/src/core/Akka/Routing/Random.cs index 5dd30297537..0de2fa203ab 100644 --- a/src/core/Akka/Routing/Random.cs +++ b/src/core/Akka/Routing/Random.cs @@ -290,7 +290,7 @@ public RandomGroup(IEnumerable paths, string routerDispatcher) /// An enumeration of actor paths used during routee selection public override IEnumerable GetPaths(ActorSystem system) { - return Paths; + return InternalPaths; } /// @@ -313,7 +313,7 @@ public override Router CreateRouter(ActorSystem system) /// A new router with the provided dispatcher id. public RandomGroup WithDispatcher(string dispatcher) { - return new RandomGroup(Paths, dispatcher); + return new RandomGroup(InternalPaths, dispatcher); } /// @@ -325,7 +325,7 @@ public override ISurrogate ToSurrogate(ActorSystem system) { return new RandomGroupSurrogate { - Paths = Paths, + Paths = InternalPaths, RouterDispatcher = RouterDispatcher }; } diff --git a/src/core/Akka/Routing/RoundRobin.cs b/src/core/Akka/Routing/RoundRobin.cs index 5f4403ae6ec..f9f7dc660b5 100644 --- a/src/core/Akka/Routing/RoundRobin.cs +++ b/src/core/Akka/Routing/RoundRobin.cs @@ -354,7 +354,7 @@ public RoundRobinGroup(IEnumerable paths, string routerDispatcher) /// An enumeration of actor paths used during routee selection public override IEnumerable GetPaths(ActorSystem system) { - return Paths; + return InternalPaths; } /// @@ -377,7 +377,7 @@ public override Router CreateRouter(ActorSystem system) /// A new router with the provided dispatcher id. public Group WithDispatcher(string dispatcherId) { - return new RoundRobinGroup(Paths, dispatcherId); + return new RoundRobinGroup(InternalPaths, dispatcherId); } /// @@ -389,7 +389,7 @@ public override ISurrogate ToSurrogate(ActorSystem system) { return new RoundRobinGroupSurrogate { - Paths = Paths, + Paths = InternalPaths, RouterDispatcher = RouterDispatcher }; } diff --git a/src/core/Akka/Routing/RoutedActorCell.cs b/src/core/Akka/Routing/RoutedActorCell.cs index b3a34cb6ecc..ff8bc6e4831 100644 --- a/src/core/Akka/Routing/RoutedActorCell.cs +++ b/src/core/Akka/Routing/RoutedActorCell.cs @@ -167,7 +167,7 @@ public override void Start() var deprecatedPaths = group.Paths; var paths = deprecatedPaths == null - ? group.GetPaths(System).ToArray() + ? group.GetPaths(System)?.ToArray() : deprecatedPaths.ToArray(); if (paths.NonEmpty()) diff --git a/src/core/Akka/Routing/RouterConfig.cs b/src/core/Akka/Routing/RouterConfig.cs index c84cccff82c..edd50569015 100644 --- a/src/core/Akka/Routing/RouterConfig.cs +++ b/src/core/Akka/Routing/RouterConfig.cs @@ -145,13 +145,20 @@ public abstract class Group : RouterConfig, IEquatable /// TBD protected Group(IEnumerable paths, string routerDispatcher) : base(routerDispatcher) { - Paths = paths; + // equivalent of turning the paths into an immutable sequence + InternalPaths = paths?.ToArray() ?? new string[0]; } /// - /// TBD + /// Internal property for holding the supplied paths + /// + protected readonly string[] InternalPaths; + + /// + /// Retrieves the paths of all routees declared on this router. /// - public IEnumerable Paths { get; } + [Obsolete("Deprecated since Akka.NET v1.1. Use Paths(ActorSystem) instead.")] + public IEnumerable Paths => null; /// /// Retrieves the actor paths used by this router during routee selection. @@ -194,7 +201,7 @@ public bool Equals(Group other) { if (ReferenceEquals(null, other)) return false; if (ReferenceEquals(this, other)) return true; - return Paths.SequenceEqual(other.Paths); + return InternalPaths.SequenceEqual(other.InternalPaths); } /// @@ -207,7 +214,7 @@ public override bool Equals(object obj) } /// - public override int GetHashCode() => Paths?.GetHashCode() ?? 0; + public override int GetHashCode() => InternalPaths?.GetHashCode() ?? 0; } /// diff --git a/src/core/Akka/Routing/ScatterGatherFirstCompleted.cs b/src/core/Akka/Routing/ScatterGatherFirstCompleted.cs index 3140b86262d..f54e0b1f88a 100644 --- a/src/core/Akka/Routing/ScatterGatherFirstCompleted.cs +++ b/src/core/Akka/Routing/ScatterGatherFirstCompleted.cs @@ -441,7 +441,7 @@ public override Router CreateRouter(ActorSystem system) /// An enumeration of actor paths used during routee selection public override IEnumerable GetPaths(ActorSystem system) { - return Paths; + return InternalPaths; } /// @@ -454,7 +454,7 @@ public override IEnumerable GetPaths(ActorSystem system) /// A new router with the provided dispatcher id. public ScatterGatherFirstCompletedGroup WithDispatcher(string dispatcher) { - return new ScatterGatherFirstCompletedGroup(Paths, Within, RouterDispatcher); + return new ScatterGatherFirstCompletedGroup(InternalPaths, Within, RouterDispatcher); } #region Surrogate @@ -467,7 +467,7 @@ public override ISurrogate ToSurrogate(ActorSystem system) { return new ScatterGatherFirstCompletedGroupSurrogate { - Paths = Paths, + Paths = InternalPaths, Within = Within, RouterDispatcher = RouterDispatcher }; diff --git a/src/core/Akka/Routing/TailChopping.cs b/src/core/Akka/Routing/TailChopping.cs index fb2ca5f6ba6..c03eca78c10 100644 --- a/src/core/Akka/Routing/TailChopping.cs +++ b/src/core/Akka/Routing/TailChopping.cs @@ -456,7 +456,7 @@ public override Router CreateRouter(ActorSystem system) /// An enumeration of actor paths used during routee selection public override IEnumerable GetPaths(ActorSystem system) { - return Paths; + return InternalPaths; } /// @@ -469,7 +469,7 @@ public override IEnumerable GetPaths(ActorSystem system) /// A new router with the provided dispatcher id. public TailChoppingGroup WithDispatcher(string dispatcher) { - return new TailChoppingGroup(Paths, Within, Interval, dispatcher); + return new TailChoppingGroup(InternalPaths, Within, Interval, dispatcher); } /// @@ -481,7 +481,7 @@ public override ISurrogate ToSurrogate(ActorSystem system) { return new TailChoppingGroupSurrogate { - Paths = Paths, + Paths = InternalPaths, Within = Within, Interval = Interval, RouterDispatcher = RouterDispatcher