Object

akka.typed

ScalaDSL

Related Doc: package typed

Permalink

object ScalaDSL

This object holds several behavior factories and combinators that can be used to construct Behavior instances.

Source
ScalaDSL.scala
Linear Supertypes
Content Hierarchy Learn more about scaladoc diagrams
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. ScalaDSL
  2. AnyRef
  3. Any
  1. Hide All
  2. Show all
Visibility
  1. Public
  2. All

Type Members

  1. final case class And[T](left: Behavior[T], right: Behavior[T]) extends Behavior[T] with Product with Serializable

    Permalink

    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$).

  2. implicit final class BehaviorDecorators[T] extends AnyVal

    Permalink
  3. final case class Full[T](behavior: PartialFunction[MessageOrSignal[T], Behavior[T]]) extends Behavior[T] with Product with Serializable

    Permalink

    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.

  4. final case class FullTotal[T](behavior: (MessageOrSignal[T]) ⇒ Behavior[T]) extends Behavior[T] with Product with Serializable

    Permalink

    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.

  5. sealed trait MessageOrSignal[T] extends AnyRef

    Permalink

    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.

  6. final case class Msg[T](ctx: ActorContext[T], msg: T) extends MessageOrSignal[T] with Product with Serializable

    Permalink

    A message bundled together with the current ActorContext.

    A message bundled together with the current ActorContext.

    Annotations
    @SerialVersionUID()
  7. final case class Or[T](left: Behavior[T], right: Behavior[T]) extends Behavior[T] with Product with Serializable

    Permalink

    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$).

  8. final case class Partial[T](behavior: PartialFunction[T, Behavior[T]]) extends Behavior[T] with Product with Serializable

    Permalink

    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.

  9. final case class Sig[T](ctx: ActorContext[T], signal: Signal) extends MessageOrSignal[T] with Product with Serializable

    Permalink

    A signal bundled together with the current ActorContext.

    A signal bundled together with the current ActorContext.

    Annotations
    @SerialVersionUID()
  10. final case class Static[T](behavior: (T) ⇒ Unit) extends Behavior[T] with Product with Serializable

    Permalink

    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.

  11. final case class SynchronousSelf[T](f: (ActorRef[T]) ⇒ Behavior[T]) extends Behavior[T] with Product with Serializable

    Permalink

    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.

  12. final case class Tap[T](f: PartialFunction[MessageOrSignal[T], Unit], behavior: Behavior[T]) extends Behavior[T] with Product with Serializable

    Permalink

    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.

  13. final case class Total[T](behavior: (T) ⇒ Behavior[T]) extends Behavior[T] with Product with Serializable

    Permalink

    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.

  14. final case class Widened[T, U >: T](behavior: Behavior[T], matcher: PartialFunction[U, T]) extends Behavior[U] with Product with Serializable

    Permalink

    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

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. def ContextAware[T](behavior: (ActorContext[T]) ⇒ Behavior[T]): Behavior[T]

    Permalink

    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 =>
          ...
      }
    }
  5. def Empty[T]: Behavior[T]

    Permalink

    This behavior does not handle any inputs, it is completely inert.

  6. def Ignore[T]: Behavior[T]

    Permalink

    This behavior does not handle any inputs, it is completely inert.

  7. def Same[T]: Behavior[T]

    Permalink

    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.

  8. def SelfAware[T](behavior: (ActorRef[T]) ⇒ Behavior[T]): Behavior[T]

    Permalink

    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
      }
    }
  9. def Stopped[T]: Behavior[T]

    Permalink

    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.

  10. object Tap extends Serializable

    Permalink
  11. def Unhandled[T]: Behavior[T]

    Permalink

    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.

  12. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  13. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  14. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  15. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  16. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  17. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  18. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  19. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  20. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  21. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  22. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  23. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  24. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  25. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  26. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  27. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from AnyRef

Inherited from Any

Ungrouped