Object

akka.typed.scaladsl

Actor

Related Doc: package scaladsl

Permalink

object Actor

Annotations
@ApiMayChange()
Source
Actor.scala
Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Actor
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Type Members

  1. implicit final class BehaviorDecorators[T] extends AnyVal

    Permalink
  2. final class Immutable[T] extends ImmutableBehavior[T]

    Permalink
  3. abstract class MutableBehavior[T] extends ExtensibleBehavior[T]

    Permalink

    Mutable behavior can be implemented by extending this class and implement the abstract method MutableBehavior#onMessage and optionally override MutableBehavior#onSignal.

    Mutable behavior can be implemented by extending this class and implement the abstract method MutableBehavior#onMessage and optionally override MutableBehavior#onSignal.

    Instances of this behavior should be created via Actor#Mutable and if the ActorContext is needed it can be passed as a constructor parameter from the factory function.

    See also

    Actor#Mutable

  4. final class Supervise[T] extends AnyVal

    Permalink

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. final def asInstanceOf[T0]: T0

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

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  6. def deferred[T](factory: (ActorContext[T]) ⇒ Behavior[T]): Behavior[T]

    Permalink

    deferred is a factory for a behavior.

    deferred is a factory for a behavior. Creation of the behavior instance is deferred until the actor is started, as opposed to Actor.immutable that creates the behavior instance immediately before the actor is running. The factory function pass the ActorContext as parameter and that can for example be used for spawning child actors.

    deferred is typically used as the outer most behavior when spawning an actor, but it can also be returned as the next behavior when processing a message or signal. In that case it will be "undeferred" immediately after it is returned, i.e. next message will be processed by the undeferred behavior.

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

    Permalink

    A behavior that treats every incoming message as unhandled.

  8. final def eq(arg0: AnyRef): Boolean

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

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

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

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

    Permalink
    Definition Classes
    AnyRef → Any
  13. def ignore[T]: Behavior[T]

    Permalink

    A behavior that ignores every incoming message and returns “same”.

  14. def immutable[T](onMessage: (ActorContext[T], T) ⇒ Behavior[T]): Immutable[T]

    Permalink

    Construct an actor behavior that can react to both incoming messages and lifecycle signals.

    Construct an actor behavior that can react to both incoming messages and lifecycle signals. After spawning this actor from another actor (or as the guardian of an akka.typed.ActorSystem) it will be executed within an ActorContext that allows access to the system, spawning and watching other actors, etc.

    This constructor is called immutable because the behavior instance does not need and in fact should not use (close over) mutable variables, but instead return a potentially different behavior encapsulating any state changes.

  15. def immutablePartial[T](onMessage: PartialFunction[(ActorContext[T], T), Behavior[T]]): Immutable[T]

    Permalink

    Construct an immutable actor behavior from a partial message handler which treats undefined messages as unhandled.

  16. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  17. def monitor[T](monitor: ActorRef[T], behavior: Behavior[T]): Behavior[T]

    Permalink

    Behavior decorator that copies all received message to the designated monitor akka.typed.ActorRef before invoking the wrapped behavior.

    Behavior decorator that copies all received message to the designated monitor akka.typed.ActorRef before invoking the wrapped behavior. The wrapped behavior can evolve (i.e. return different behavior) without needing to be wrapped in a monitor call again.

  18. def mutable[T](factory: (ActorContext[T]) ⇒ MutableBehavior[T]): Behavior[T]

    Permalink

    Factory for creating a MutableBehavior that typically holds mutable state as instance variables in the concrete MutableBehavior implementation class.

    Factory for creating a MutableBehavior that typically holds mutable state as instance variables in the concrete MutableBehavior implementation class.

    Creation of the behavior instance is deferred, i.e. it is created via the factory function. The reason for the deferred creation is to avoid sharing the same instance in multiple actors, and to create a new instance when the actor is restarted.

    returns

    the deferred behavior

  19. final def ne(arg0: AnyRef): Boolean

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

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

    Permalink
    Definition Classes
    AnyRef
  22. def onSignal[T](handler: PartialFunction[(ActorContext[T], Signal), Behavior[T]]): Behavior[T]

    Permalink

    Construct an actor behavior that can react to lifecycle signals only.

  23. 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.

  24. def stopped[T](postStop: Behavior[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 be passed to the given postStop behavior. All other messages and signals will effectively be ignored.

  25. 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 be passed to the current behavior. All other messages and signals will effectively be ignored.

  26. def supervise[T](wrapped: Behavior[T]): Supervise[T]

    Permalink

    Wrap the given behavior such that it is restarted (i.e.

    Wrap the given behavior such that it is restarted (i.e. reset to its initial state) whenever it throws an exception of the given class or a subclass thereof. Exceptions that are not subtypes of Thr will not be caught and thus lead to the termination of the actor.

    It is possible to specify different supervisor strategies, such as restart, resume, backoff.

    Note that only scala.util.control.NonFatal throwables will trigger the supervision strategy.

    Example:

    val dbConnector: Behavior[DbCommand] = ...
    
    val dbRestarts =
       Actor.supervise(dbConnector)
         .onFailure(SupervisorStrategy.restart) // handle all NonFatal exceptions
    
    val dbSpecificResumes =
       Actor.supervise(dbConnector)
         .onFailure[IndexOutOfBoundsException](SupervisorStrategy.resume) // resume for IndexOutOfBoundsException exceptions
  27. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  28. def tap[T](onMessage: Function2[ActorContext[T], T, _], onSignal: Function2[ActorContext[T], Signal, _], behavior: Behavior[T]): Behavior[T]

    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.

  29. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  30. 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.

  31. final def wait(): Unit

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

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

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  34. def withTimers[T](factory: (TimerScheduler[T]) ⇒ Behavior[T]): Behavior[T]

    Permalink

    Support for scheduled self messages in an actor.

    Support for scheduled self messages in an actor. It takes care of the lifecycle of the timers such as cancelling them when the actor is restarted or stopped.

    See also

    TimerScheduler

Inherited from AnyRef

Inherited from Any

Ungrouped