Merge pull request #29181 from johanandren/wip-29081-optional-settings-sharded-daemon-process

This commit is contained in:
Renato Cavalcanti 2020-06-05 12:08:23 +02:00 committed by GitHub
commit 7a29543545
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 42 additions and 2 deletions

View file

@ -0,0 +1,3 @@
# Non-settings stop message overload for Sharded Daemon Process #29081
ProblemFilters.exclude[ReversedMissingMethodProblem]("akka.cluster.sharding.typed.scaladsl.ShardedDaemonProcess.init")
ProblemFilters.exclude[ReversedMissingMethodProblem]("akka.cluster.sharding.typed.javadsl.ShardedDaemonProcess.init")

View file

@ -93,9 +93,12 @@ private[akka] final class ShardedDaemonProcessImpl(system: ActorSystem[_])
import ShardedDaemonProcessImpl._
def init[T](name: String, numberOfInstances: Int, behaviorFactory: Int => Behavior[T])(
implicit classTag: ClassTag[T]): Unit = {
implicit classTag: ClassTag[T]): Unit =
init(name, numberOfInstances, behaviorFactory, ShardedDaemonProcessSettings(system), None)(classTag)
}
override def init[T](name: String, numberOfInstances: Int, behaviorFactory: Int => Behavior[T], stopMessage: T)(
implicit classTag: ClassTag[T]): Unit =
init(name, numberOfInstances, behaviorFactory, ShardedDaemonProcessSettings(system), Some(stopMessage))(classTag)
def init[T](
name: String,
@ -153,6 +156,7 @@ private[akka] final class ShardedDaemonProcessImpl(system: ActorSystem[_])
}
}
// Java API
def init[T](
messageClass: Class[T],
name: String,
@ -160,6 +164,15 @@ private[akka] final class ShardedDaemonProcessImpl(system: ActorSystem[_])
behaviorFactory: function.Function[Integer, Behavior[T]]): Unit =
init(name, numberOfInstances, n => behaviorFactory(n))(ClassTag(messageClass))
override def init[T](
messageClass: Class[T],
name: String,
numberOfInstances: Int,
behaviorFactory: function.Function[Int, Behavior[T]],
stopMessage: T): Unit =
init(name, numberOfInstances, n => behaviorFactory(n), ShardedDaemonProcessSettings(system), Some(stopMessage))(
ClassTag(messageClass))
def init[T](
messageClass: Class[T],
name: String,

View file

@ -45,6 +45,20 @@ abstract class ShardedDaemonProcess {
numberOfInstances: Int,
behaviorFactory: function.Function[Integer, Behavior[T]]): Unit
/**
* Start a specific number of actors that is then kept alive in the cluster.
*
* @param behaviorFactory Given a unique id of `0` until `numberOfInstance` create the behavior for that actor.
* @param stopMessage sent to the actors when they need to stop because of a rebalance across the nodes of the cluster
* or cluster shutdown.
*/
def init[T](
messageClass: Class[T],
name: String,
numberOfInstances: Int,
behaviorFactory: function.Function[Int, Behavior[T]],
stopMessage: T): Unit
/**
* Start a specific number of actors, each with a unique numeric id in the set, that is then kept alive in the cluster.
* @param behaviorFactory Given a unique id of `0` until `numberOfInstance` create the behavior for that actor.

View file

@ -45,6 +45,16 @@ trait ShardedDaemonProcess extends Extension { javadslSelf: javadsl.ShardedDaemo
def init[T](name: String, numberOfInstances: Int, behaviorFactory: Int => Behavior[T])(
implicit classTag: ClassTag[T]): Unit
/**
* Start a specific number of actors that is then kept alive in the cluster.
*
* @param behaviorFactory Given a unique id of `0` until `numberOfInstance` create the behavior for that actor.
* @param stopMessage sent to the actors when they need to stop because of a rebalance across the nodes of the cluster
* or cluster shutdown.
*/
def init[T](name: String, numberOfInstances: Int, behaviorFactory: Int => Behavior[T], stopMessage: T)(
implicit classTag: ClassTag[T]): Unit
/**
* Start a specific number of actors, each with a unique numeric id in the set, that is then kept alive in the cluster.
* @param behaviorFactory Given a unique id of `0` until `numberOfInstance` create the behavior for that actor.