object ScalaDSL
This object holds several behavior factories and combinators that can be used to construct Behavior instances.
- Source
- ScalaDSL.scala
- Alphabetic
- By Inheritance
- ScalaDSL
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Type Members
-
final
case class
And
[T](left: Behavior[T], right: Behavior[T]) extends Behavior[T] with Product with Serializable
A behavior combinator that feeds incoming messages and signals both into the left and right sub-behavior and allows them to evolve independently of each other.
A behavior combinator that feeds incoming messages and signals both into the left and right sub-behavior and allows them to evolve independently of each other. When one of the sub-behaviors terminates the other takes over exclusively. When both sub-behaviors respond to a Failed signal, the response with the higher precedence is chosen (see Failed$).
- implicit final class BehaviorDecorators [T] extends AnyVal
-
final
case class
Deferred
[T](factory: () ⇒ Behavior[T]) extends Behavior[T] with Product with Serializable
Wrap a behavior factory so that it runs upon PreStart, i.e.
Wrap a behavior factory so that it runs upon PreStart, i.e. behavior creation is deferred to the child actor instead of running within the parent.
-
final
case class
Full
[T](behavior: PartialFunction[MessageOrSignal[T], Behavior[T]]) extends Behavior[T] with Product with Serializable
This type of behavior allows to handle all incoming messages within the same user-provided partial function, be that a user message or a system signal.
This type of behavior allows to handle all incoming messages within the same user-provided partial function, be that a user message or a system signal. For messages that do not match the partial function the same behavior is emitted without change. This does entail that unhandled failures of child actors will lead to a failure in this actor.
For the lifecycle notifications pertaining to the actor itself this behavior includes a fallback mechanism: an unhandled PreRestart signal will terminate all child actors (transitively) and then emit a PostStop signal in addition, whereas an unhandled PostRestart signal will emit an additional PreStart signal.
-
final
case class
FullTotal
[T](behavior: (MessageOrSignal[T]) ⇒ Behavior[T]) extends Behavior[T] with Product with Serializable
This type of behavior expects a total function that describes the actor’s reaction to all system signals or user messages, without providing a fallback mechanism for either.
This type of behavior expects a total function that describes the actor’s reaction to all system signals or user messages, without providing a fallback mechanism for either. If you use partial function literal syntax to create the supplied function then any message not matching the list of cases will fail this actor with a scala.MatchError.
-
sealed
trait
MessageOrSignal
[T] extends AnyRef
Algebraic Data Type modeling either a message or a signal, including the ActorContext.
Algebraic Data Type modeling either a message or a signal, including the ActorContext. This type is used by several of the behaviors defined in this DSL, see for example Full.
-
final
case class
Msg
[T](ctx: ActorContext[T], msg: T) extends MessageOrSignal[T] with Product with Serializable
A message bundled together with the current ActorContext.
A message bundled together with the current ActorContext.
- Annotations
- @SerialVersionUID()
-
final
case class
Or
[T](left: Behavior[T], right: Behavior[T]) extends Behavior[T] with Product with Serializable
A behavior combinator that feeds incoming messages and signals either into the left or right sub-behavior and allows them to evolve independently of each other.
A behavior combinator that feeds incoming messages and signals either into the left or right sub-behavior and allows them to evolve independently of each other. The message or signal is passed first into the left sub-behavior and only if that results in #Unhandled is it passed to the right sub-behavior. When one of the sub-behaviors terminates the other takes over exclusively. When both sub-behaviors respond to a Failed signal, the response with the higher precedence is chosen (see Failed$).
-
final
case class
Partial
[T](behavior: PartialFunction[T, Behavior[T]]) extends Behavior[T] with Product with Serializable
This type of Behavior is created from a partial function from the declared message type to the next behavior, flagging all unmatched messages as #Unhandled.
This type of Behavior is created from a partial function from the declared message type to the next behavior, flagging all unmatched messages as #Unhandled. All system signals are ignored by this behavior, which implies that a failure of a child actor will be escalated unconditionally.
This behavior type is most useful for leaf actors that do not create child actors themselves.
-
final
case class
Sig
[T](ctx: ActorContext[T], signal: Signal) extends MessageOrSignal[T] with Product with Serializable
A signal bundled together with the current ActorContext.
A signal bundled together with the current ActorContext.
- Annotations
- @SerialVersionUID()
-
final
case class
Static
[T](behavior: (T) ⇒ Unit) extends Behavior[T] with Product with Serializable
This type of behavior is a variant of Total that does not allow the actor to change behavior.
This type of behavior is a variant of Total that does not allow the actor to change behavior. It is an efficient choice for stateless actors, possibly entering such a behavior after finishing its initialization (which may be modeled using any of the other behavior types).
This behavior type is most useful for leaf actors that do not create child actors themselves.
-
final
case class
SynchronousSelf
[T](f: (ActorRef[T]) ⇒ Behavior[T]) extends Behavior[T] with Product with Serializable
This behavior allows sending messages to itself without going through the Actor’s mailbox.
This behavior allows sending messages to itself without going through the Actor’s mailbox. A message sent like this will be processed before the next message is taken out of the mailbox. In case of Actor failures outstanding messages that were sent to the synchronous self reference will be lost.
This decorator is useful for passing messages between the left and right sides of And and Or combinators.
-
final
case class
Tap
[T](f: PartialFunction[MessageOrSignal[T], Unit], behavior: Behavior[T]) extends Behavior[T] with Product with Serializable
This type of Behavior wraps another Behavior while allowing you to perform some action upon each received message or signal.
This type of Behavior wraps another Behavior while allowing you to perform some action upon each received message or signal. It is most commonly used for logging or tracing what a certain Actor does.
-
final
case class
Total
[T](behavior: (T) ⇒ Behavior[T]) extends Behavior[T] with Product with Serializable
This type of behavior is created from a total function from the declared message type to the next behavior, which means that all possible incoming messages for the given type must be handled.
This type of behavior is created from a total function from the declared message type to the next behavior, which means that all possible incoming messages for the given type must be handled. All system signals are ignored by this behavior, which implies that a failure of a child actor will be escalated unconditionally.
This behavior type is most useful for leaf actors that do not create child actors themselves.
-
final
case class
Widened
[T, U >: T](behavior: Behavior[T], matcher: PartialFunction[U, T]) extends Behavior[U] with Product with Serializable
Widen the wrapped Behavior by placing a funnel in front of it: the supplied PartialFunction decides which message to pull in (those that it is defined at) and may transform the incoming message to place them into the wrapped Behavior’s type hierarchy.
Widen the wrapped Behavior by placing a funnel in front of it: the supplied PartialFunction decides which message to pull in (those that it is defined at) and may transform the incoming message to place them into the wrapped Behavior’s type hierarchy. Signals are not transformed.
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
ContextAware[T](behavior: (ActorContext[T]) ⇒ Behavior[T]): Behavior[T]
A behavior decorator that extracts the ActorContext while receiving the the first signal or message and uses that to construct the real behavior (which will then also receive that signal or message).
A behavior decorator that extracts the ActorContext while receiving the the first signal or message and uses that to construct the real behavior (which will then also receive that signal or message).
Example:
ContextAware[MyCommand] { ctx => Simple { case cmd => ... } }
-
def
Empty[T]: Behavior[T]
This behavior does not handle any inputs, it is completely inert.
-
def
Ignore[T]: Behavior[T]
This behavior does not handle any inputs, it is completely inert.
-
def
Same[T]: Behavior[T]
Return this behavior from message processing in order to advise the system to reuse the previous behavior.
Return this behavior from message processing in order to advise the system to reuse the previous behavior. This is provided in order to avoid the allocation overhead of recreating the current behavior where that is not necessary.
-
def
SelfAware[T](behavior: (ActorRef[T]) ⇒ Behavior[T]): Behavior[T]
A behavior decorator that extracts the self ActorRef while receiving the the first signal or message and uses that to construct the real behavior (which will then also receive that signal or message).
A behavior decorator that extracts the self ActorRef while receiving the the first signal or message and uses that to construct the real behavior (which will then also receive that signal or message).
Example:
SelfAware[MyCommand] { self => Simple { case cmd => } }
This can also be used together with implicitly sender-capturing message types:
final case class OtherMsg(msg: String)(implicit val replyTo: ActorRef[Reply]) SelfAware[MyCommand] { implicit self => Simple { case cmd => other ! OtherMsg("hello") // assuming Reply <: MyCommand } }
-
def
Stopped[T]: Behavior[T]
Return this behavior from message processing to signal that this actor shall terminate voluntarily.
Return this behavior from message processing to signal that this actor shall terminate voluntarily. If this actor has created child actors then these will be stopped as part of the shutdown procedure. The PostStop signal that results from stopping this actor will NOT be passed to the current behavior, it will be effectively ignored.
-
def
Unhandled[T]: Behavior[T]
Return this behavior from message processing in order to advise the system to reuse the previous behavior, including the hint that the message has not been handled.
Return this behavior from message processing in order to advise the system to reuse the previous behavior, including the hint that the message has not been handled. This hint may be used by composite behaviors that delegate (partial) handling to other behaviors.
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
finalize(): Unit
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
- object Tap extends Serializable