DOC: Props.empty.withRouter, see #3464
This commit is contained in:
parent
1cca2b85e3
commit
7c3f6c21d8
5 changed files with 13 additions and 7 deletions
|
|
@ -29,7 +29,7 @@ object RoutingProgrammaticallyExample extends App {
|
|||
val actor2 = system.actorOf(Props[ExampleActor1])
|
||||
val actor3 = system.actorOf(Props[ExampleActor1])
|
||||
val routees = Vector[ActorRef](actor1, actor2, actor3)
|
||||
val router2 = system.actorOf(Props().withRouter(
|
||||
val router2 = system.actorOf(Props.empty.withRouter(
|
||||
RoundRobinRouter(routees = routees)))
|
||||
//#programmaticRoutingRoutees
|
||||
1 to 6 foreach { i ⇒ router2 ! Message1(i) }
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ public class FactorialFrontend extends UntypedActor {
|
|||
LoggingAdapter log = Logging.getLogger(getContext().system(), this);
|
||||
|
||||
ActorRef backend = getContext().actorOf(
|
||||
Props.create(FactorialBackend.class).withRouter(FromConfig.getInstance()),
|
||||
Props.empty().withRouter(FromConfig.getInstance()),
|
||||
"factorialBackendRouter");
|
||||
|
||||
public FactorialFrontend(int upToN, boolean repeat) {
|
||||
|
|
@ -66,7 +66,7 @@ abstract class FactorialFrontend2 extends UntypedActor {
|
|||
boolean allowLocalRoutees = true;
|
||||
String useRole = "backend";
|
||||
ActorRef backend = getContext().actorOf(
|
||||
Props.create(FactorialBackend.class).withRouter(new ClusterRouterConfig(
|
||||
Props.empty().withRouter(new ClusterRouterConfig(
|
||||
new AdaptiveLoadBalancingRouter(HeapMetricsSelector.getInstance(), 0),
|
||||
new ClusterRouterSettings(
|
||||
totalInstances, routeesPath, allowLocalRoutees, useRole))),
|
||||
|
|
|
|||
|
|
@ -15,6 +15,9 @@ import akka.routing.FromConfig;
|
|||
//#service
|
||||
public class StatsService extends UntypedActor {
|
||||
|
||||
// This router is used both with lookup and deploy of routees. If you
|
||||
// have a router with only lookup of routees you can use Props.empty()
|
||||
// instead of Props.create(StatsWorker.class).
|
||||
ActorRef workerRouter = getContext().actorOf(
|
||||
Props.create(StatsWorker.class).withRouter(FromConfig.getInstance()),
|
||||
"workerRouter");
|
||||
|
|
@ -56,7 +59,7 @@ abstract class StatsService2 extends UntypedActor {
|
|||
boolean allowLocalRoutees = true;
|
||||
String useRole = "compute";
|
||||
ActorRef workerRouter = getContext().actorOf(
|
||||
Props.create(StatsWorker.class).withRouter(new ClusterRouterConfig(
|
||||
Props.empty().withRouter(new ClusterRouterConfig(
|
||||
new ConsistentHashingRouter(0), new ClusterRouterSettings(
|
||||
totalInstances, routeesPath, allowLocalRoutees, useRole))),
|
||||
"workerRouter2");
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ object FactorialFrontend {
|
|||
//#frontend
|
||||
class FactorialFrontend(upToN: Int, repeat: Boolean) extends Actor with ActorLogging {
|
||||
|
||||
val backend = context.actorOf(Props[FactorialBackend].withRouter(FromConfig),
|
||||
val backend = context.actorOf(Props.empty.withRouter(FromConfig),
|
||||
name = "factorialBackendRouter")
|
||||
|
||||
override def preStart(): Unit = sendJobs()
|
||||
|
|
@ -146,7 +146,7 @@ abstract class FactorialFrontend2 extends Actor {
|
|||
import akka.cluster.routing.AdaptiveLoadBalancingRouter
|
||||
import akka.cluster.routing.HeapMetricsSelector
|
||||
|
||||
val backend = context.actorOf(Props[FactorialBackend].withRouter(
|
||||
val backend = context.actorOf(Props.empty.withRouter(
|
||||
ClusterRouterConfig(AdaptiveLoadBalancingRouter(HeapMetricsSelector),
|
||||
ClusterRouterSettings(
|
||||
totalInstances = 100, routeesPath = "/user/factorialBackend",
|
||||
|
|
|
|||
|
|
@ -34,6 +34,9 @@ case class JobFailed(reason: String)
|
|||
|
||||
//#service
|
||||
class StatsService extends Actor {
|
||||
// This router is used both with lookup and deploy of routees. If you
|
||||
// have a router with only lookup of routees you can use Props.empty
|
||||
// instead of Props[StatsWorker.class].
|
||||
val workerRouter = context.actorOf(Props[StatsWorker].withRouter(FromConfig),
|
||||
name = "workerRouter")
|
||||
|
||||
|
|
@ -225,7 +228,7 @@ abstract class StatsService2 extends Actor {
|
|||
import akka.cluster.routing.ClusterRouterSettings
|
||||
import akka.routing.ConsistentHashingRouter
|
||||
|
||||
val workerRouter = context.actorOf(Props[StatsWorker].withRouter(
|
||||
val workerRouter = context.actorOf(Props.empty.withRouter(
|
||||
ClusterRouterConfig(ConsistentHashingRouter(), ClusterRouterSettings(
|
||||
totalInstances = 100, routeesPath = "/user/statsWorker",
|
||||
allowLocalRoutees = true, useRole = Some("compute")))),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue