Packages

  • package root
    Definition Classes
    root
  • package org
    Definition Classes
    root
  • package apache
    Definition Classes
    org
  • package pekko
    Definition Classes
    apache
  • package actor
    Definition Classes
    pekko
  • trait FSM[S, D] extends Actor with Listeners with ActorLogging

    Finite State Machine actor trait.

    Finite State Machine actor trait. Use as follows:

      object A {
        trait State
        case class One extends State
        case class Two extends State
    
        case class Data(i : Int)
      }
    
      class A extends Actor with FSM[A.State, A.Data] {
        import A._
    
        startWith(One, Data(42))
        when(One) {
            case Event(SomeMsg, Data(x)) => ...
            case Event(SomeOtherMsg, _) => ... // when data not needed
        }
        when(Two, stateTimeout = 5 seconds) { ... }
        initialize()
      }
    

    Within the partial function the following values are returned for effecting state transitions:

    • stay for staying in the same state
    • stay using Data(...) for staying in the same state, but with different data
    • stay forMax 5.millis for staying with a state timeout; can be combined with using
    • goto(...) for changing into a different state; also supports using and forMax
    • stop for terminating this FSM actor

    Each of the above also supports the method replying(AnyRef) for sending a reply before changing state.

    While changing state, custom handlers may be invoked which are registered using onTransition. This is meant to enable concentrating different concerns in different places; you may choose to use when for describing the properties of a state, including of course initiating transitions, but you can describe the transitions using onTransition to avoid having to duplicate that code among multiple paths which lead to a transition:

    onTransition {
      case Active -> _ => cancelTimer("activeTimer")
    }
    

    Multiple such blocks are supported and all of them will be called, not only the first matching one.

    Another feature is that other actors may subscribe for transition events by sending a SubscribeTransitionCallback message to this actor. Stopping a listener without unregistering will not remove the listener from the subscription list; use UnsubscribeTransitionCallback before stopping the listener.

    State timeouts set an upper bound to the time which may pass before another message is received in the current state. If no external message is available, then upon expiry of the timeout a StateTimeout message is sent. Note that this message will only be received in the state for which the timeout was set and that any message received will cancel the timeout (possibly to be started again by the next transition).

    Another feature is the ability to install and cancel single-shot as well as repeated timers which arrange for the sending of a user-specified message:

      setTimer("tock", TockMsg, 1 second, true) // repeating
      setTimer("lifetime", TerminateMsg, 1 hour, false) // single-shot
      cancelTimer("tock")
      isTimerActive("tock")
    

    Definition Classes
    actor
  • TransformHelper
c

org.apache.pekko.actor.FSM

TransformHelper

final class TransformHelper extends AnyRef

Source
FSM.scala
Linear Supertypes
Type Hierarchy
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. TransformHelper
  2. AnyRef
  3. Any
Implicitly
  1. by any2stringadd
  2. by StringFormat
  3. by Ensuring
  4. by ArrowAssoc
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Instance Constructors

  1. new TransformHelper(func: StateFunction)

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##: Int
    Definition Classes
    AnyRef → Any
  3. def +(other: String): String
    Implicit
    This member is added by an implicit conversion from TransformHelper toany2stringadd[TransformHelper] performed by method any2stringadd in scala.Predef.
    Definition Classes
    any2stringadd
  4. def ->[B](y: B): (TransformHelper, B)
    Implicit
    This member is added by an implicit conversion from TransformHelper toArrowAssoc[TransformHelper] performed by method ArrowAssoc in scala.Predef.
    Definition Classes
    ArrowAssoc
    Annotations
    @inline()
  5. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  6. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  7. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @HotSpotIntrinsicCandidate() @native()
  8. def ensuring(cond: (TransformHelper) => Boolean, msg: => Any): TransformHelper
    Implicit
    This member is added by an implicit conversion from TransformHelper toEnsuring[TransformHelper] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  9. def ensuring(cond: (TransformHelper) => Boolean): TransformHelper
    Implicit
    This member is added by an implicit conversion from TransformHelper toEnsuring[TransformHelper] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  10. def ensuring(cond: Boolean, msg: => Any): TransformHelper
    Implicit
    This member is added by an implicit conversion from TransformHelper toEnsuring[TransformHelper] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  11. def ensuring(cond: Boolean): TransformHelper
    Implicit
    This member is added by an implicit conversion from TransformHelper toEnsuring[TransformHelper] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  12. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  13. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  14. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @HotSpotIntrinsicCandidate() @native()
  15. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @HotSpotIntrinsicCandidate() @native()
  16. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  17. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  18. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @HotSpotIntrinsicCandidate() @native()
  19. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @HotSpotIntrinsicCandidate() @native()
  20. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  21. def toString(): String
    Definition Classes
    AnyRef → Any
  22. def using(andThen: PartialFunction[State, State]): StateFunction
  23. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  24. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()
  25. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])

Deprecated Value Members

  1. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable]) @Deprecated
    Deprecated

    (Since version 9)

  2. def formatted(fmtstr: String): String
    Implicit
    This member is added by an implicit conversion from TransformHelper toStringFormat[TransformHelper] performed by method StringFormat in scala.Predef.
    Definition Classes
    StringFormat
    Annotations
    @deprecated @inline()
    Deprecated

    (Since version 2.12.16) Use formatString.format(value) instead of value.formatted(formatString), or use the f"" string interpolator. In Java 15 and later, formatted resolves to the new method in String which has reversed parameters.

  3. def [B](y: B): (TransformHelper, B)
    Implicit
    This member is added by an implicit conversion from TransformHelper toArrowAssoc[TransformHelper] performed by method ArrowAssoc in scala.Predef.
    Definition Classes
    ArrowAssoc
    Annotations
    @deprecated
    Deprecated

    (Since version 2.13.0) Use -> instead. If you still wish to display it as one character, consider using a font with programming ligatures such as Fira Code.

Inherited from AnyRef

Inherited from Any

Inherited by implicit conversion any2stringadd fromTransformHelper to any2stringadd[TransformHelper]

Inherited by implicit conversion StringFormat fromTransformHelper to StringFormat[TransformHelper]

Inherited by implicit conversion Ensuring fromTransformHelper to Ensuring[TransformHelper]

Inherited by implicit conversion ArrowAssoc fromTransformHelper to ArrowAssoc[TransformHelper]

Ungrouped