Interface PersistentFSMBase<S,D,E>
-
- All Superinterfaces:
Actor
,ActorLogging
,Listeners
- All Known Subinterfaces:
LoggingPersistentFSM<S,D,E>
,PersistentFSM<S,D,E>
- All Known Implementing Classes:
AbstractPersistentFSM
,AbstractPersistentFSMBase
,AbstractPersistentLoggingFSM
public interface PersistentFSMBase<S,D,E> extends Actor, Listeners, ActorLogging
Deprecated.Use EventSourcedBehavior. Since 2.6.0.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, _) => ... // convenience 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 withusing
-goto(...)
for changing into a different state; also supportsusing
andforMax
-stop
for terminating this FSM actorEach 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 usewhen
for describing the properties of a state, including of course initiating transitions, but you can describe the transitions usingonTransition
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; useUnsubscribeTransitionCallback
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:
startTimerWithFixedDelay("tock", TockMsg, 1 second) // repeating startSingleTimer("lifetime", TerminateMsg, 1 hour) // single-shot cancelTimer("tock") isTimerActive("tock")
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
PersistentFSMBase.TransformHelper
Deprecated.-
Nested classes/interfaces inherited from interface akka.actor.Actor
Actor.emptyBehavior$, Actor.ignoringBehavior$
-
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description PersistentFSM.$minus$greater$
$minus$greater()
Deprecated.This extractor is just convenience for matching a (S, S) pair, including a reminder what the new state is.void
akka$persistence$fsm$PersistentFSMBase$_setter_$Event_$eq(PersistentFSM.Event$ x$1)
Deprecated.void
akka$persistence$fsm$PersistentFSMBase$_setter_$StateTimeout_$eq(PersistentFSM.StateTimeout$ x$1)
Deprecated.This case object is received in case of a state timeout.void
akka$persistence$fsm$PersistentFSMBase$_setter_$StopEvent_$eq(PersistentFSM.StopEvent$ x$1)
Deprecated.void
applyState(PersistentFSM.State<S,D,E> nextState)
Deprecated.void
cancelTimer(java.lang.String name)
Deprecated.void
currentState_$eq(PersistentFSM.State<S,D,E> x$1)
Deprecated.boolean
debugEvent()
Deprecated.PersistentFSM.Event$
Event()
Deprecated.void
generation_$eq(long x$1)
Deprecated.void
handleEvent_$eq(scala.PartialFunction<PersistentFSM.Event<D>,PersistentFSM.State<S,D,E>> x$1)
Deprecated.void
handleTransition(S prev, S next)
Deprecated.void
initialize()
Deprecated.Removed from API, called internally.boolean
isStateTimerActive()
Deprecated.boolean
isTimerActive(java.lang.String name)
Deprecated.void
logTermination(PersistentFSM.Reason reason)
Deprecated.By defaultPersistentFSM.Failure
is logged at error level and other reason types are not logged.void
makeTransition(PersistentFSM.State<S,D,E> nextState)
Deprecated.void
nextState_$eq(PersistentFSM.State<S,D,E> x$1)
Deprecated.D
nextStateData()
Deprecated.void
onTermination(scala.PartialFunction<PersistentFSM.StopEvent<S,D>,scala.runtime.BoxedUnit> terminationHandler)
Deprecated.void
onTransition(scala.PartialFunction<scala.Tuple2<S,S>,scala.runtime.BoxedUnit> transitionHandler)
Deprecated.void
postStop()
Deprecated.User overridable callback.void
processEvent(PersistentFSM.Event<D> event, java.lang.Object source)
Deprecated.void
processMsg(java.lang.Object value, java.lang.Object source)
Deprecated.scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit>
receive()
Deprecated.Scala API: This defines the initial actor behavior, it must return a partial function with the actor logic.void
register(S name, scala.PartialFunction<PersistentFSM.Event<D>,PersistentFSM.State<S,D,E>> function, scala.Option<scala.concurrent.duration.FiniteDuration> timeout)
Deprecated.void
setStateTimeout(S state, scala.Option<scala.concurrent.duration.FiniteDuration> timeout)
Deprecated.void
setTimer(java.lang.String name, java.lang.Object msg, scala.concurrent.duration.FiniteDuration timeout, boolean repeat)
Deprecated.Use startSingleTimer, startTimerWithFixedDelay or startTimerAtFixedRate instead.boolean
setTimer$default$4()
Deprecated.void
startSingleTimer(java.lang.String name, java.lang.Object msg, scala.concurrent.duration.FiniteDuration delay)
Deprecated.void
startTimer(java.lang.String name, java.lang.Object msg, scala.concurrent.duration.FiniteDuration timeout, PersistentFSM.TimerMode mode)
Deprecated.void
startTimerAtFixedRate(java.lang.String name, java.lang.Object msg, scala.concurrent.duration.FiniteDuration interval)
Deprecated.void
startTimerWithFixedDelay(java.lang.String name, java.lang.Object msg, scala.concurrent.duration.FiniteDuration delay)
Deprecated.void
startWith(S stateName, D stateData, scala.Option<scala.concurrent.duration.FiniteDuration> timeout)
Deprecated.Set initial state.scala.Option<scala.concurrent.duration.FiniteDuration>
startWith$default$3()
Deprecated.D
stateData()
Deprecated.S
stateName()
Deprecated.scala.collection.Iterable<S>
stateNames()
Deprecated.PersistentFSM.StateTimeout$
StateTimeout()
Deprecated.This case object is received in case of a state timeout.PersistentFSM.State<S,D,E>
stay()
Deprecated.Produce "empty" transition descriptor.PersistentFSM.State<S,D,E>
stop()
Deprecated.Produce change descriptor to stop this FSM actor with reason "Normal".PersistentFSM.State<S,D,E>
stop(PersistentFSM.Reason reason)
Deprecated.Produce change descriptor to stop this FSM actor including specified reason.PersistentFSM.State<S,D,E>
stop(PersistentFSM.Reason reason, D stateData)
Deprecated.Produce change descriptor to stop this FSM actor including specified reason.PersistentFSM.StopEvent$
StopEvent()
Deprecated.void
super$postStop()
Deprecated.CallonTermination
hook; if you want to retain this behavior when overriding make sure to callsuper.postStop()
.void
terminate(PersistentFSM.State<S,D,E> nextState)
Deprecated.void
terminateEvent_$eq(scala.PartialFunction<PersistentFSM.StopEvent<S,D>,scala.runtime.BoxedUnit> x$1)
Deprecated.void
timeoutFuture_$eq(scala.Option<Cancellable> x$1)
Deprecated.scala.PartialFunction<scala.Tuple2<S,S>,scala.runtime.BoxedUnit>
total2pf(scala.Function2<S,S,scala.runtime.BoxedUnit> transitionHandler)
Deprecated.PersistentFSMBase.TransformHelper
transform(scala.PartialFunction<PersistentFSM.Event<D>,PersistentFSM.State<S,D,E>> func)
Deprecated.void
transitionEvent_$eq(scala.collection.immutable.List<scala.PartialFunction<scala.Tuple2<S,S>,scala.runtime.BoxedUnit>> x$1)
Deprecated.void
when(S stateName, scala.concurrent.duration.FiniteDuration stateTimeout, scala.PartialFunction<PersistentFSM.Event<D>,PersistentFSM.State<S,D,E>> stateFunction)
Deprecated.Insert a new StateFunction at the end of the processing chain for the given state.scala.concurrent.duration.FiniteDuration
when$default$2()
Deprecated.void
whenUnhandled(scala.PartialFunction<PersistentFSM.Event<D>,PersistentFSM.State<S,D,E>> stateFunction)
Deprecated.-
Methods inherited from interface akka.actor.Actor
akka$actor$Actor$_setter_$context_$eq, akka$actor$Actor$_setter_$self_$eq, aroundPostRestart, aroundPostStop, aroundPreRestart, aroundPreStart, aroundReceive, context, postRestart, preRestart, preStart, self, sender, supervisorStrategy, unhandled
-
Methods inherited from interface akka.actor.ActorLogging
_log_$eq, log
-
Methods inherited from interface akka.routing.Listeners
akka$routing$Listeners$_setter_$listeners_$eq, gossip, gossip$default$2, listenerManagement, listeners
-
-
-
-
Method Detail
-
$minus$greater
PersistentFSM.$minus$greater$ $minus$greater()
Deprecated.This extractor is just convenience for matching a (S, S) pair, including a reminder what the new state is.
-
Event
PersistentFSM.Event$ Event()
Deprecated.
-
StateTimeout
PersistentFSM.StateTimeout$ StateTimeout()
Deprecated.This case object is received in case of a state timeout.
-
StopEvent
PersistentFSM.StopEvent$ StopEvent()
Deprecated.
-
akka$persistence$fsm$PersistentFSMBase$_setter_$Event_$eq
void akka$persistence$fsm$PersistentFSMBase$_setter_$Event_$eq(PersistentFSM.Event$ x$1)
Deprecated.
-
akka$persistence$fsm$PersistentFSMBase$_setter_$StateTimeout_$eq
void akka$persistence$fsm$PersistentFSMBase$_setter_$StateTimeout_$eq(PersistentFSM.StateTimeout$ x$1)
Deprecated.This case object is received in case of a state timeout.
-
akka$persistence$fsm$PersistentFSMBase$_setter_$StopEvent_$eq
void akka$persistence$fsm$PersistentFSMBase$_setter_$StopEvent_$eq(PersistentFSM.StopEvent$ x$1)
Deprecated.
-
applyState
void applyState(PersistentFSM.State<S,D,E> nextState)
Deprecated.
-
cancelTimer
void cancelTimer(java.lang.String name)
Deprecated.
-
currentState_$eq
void currentState_$eq(PersistentFSM.State<S,D,E> x$1)
Deprecated.
-
debugEvent
boolean debugEvent()
Deprecated.
-
generation_$eq
void generation_$eq(long x$1)
Deprecated.
-
handleEvent_$eq
void handleEvent_$eq(scala.PartialFunction<PersistentFSM.Event<D>,PersistentFSM.State<S,D,E>> x$1)
Deprecated.
-
initialize
void initialize()
Deprecated.Removed from API, called internally. Since 2.4.5.
-
isStateTimerActive
boolean isStateTimerActive()
Deprecated.
-
isTimerActive
boolean isTimerActive(java.lang.String name)
Deprecated.
-
logTermination
void logTermination(PersistentFSM.Reason reason)
Deprecated.By defaultPersistentFSM.Failure
is logged at error level and other reason types are not logged. It is possible to override this behavior.
-
makeTransition
void makeTransition(PersistentFSM.State<S,D,E> nextState)
Deprecated.
-
nextStateData
D nextStateData()
Deprecated.
-
nextState_$eq
void nextState_$eq(PersistentFSM.State<S,D,E> x$1)
Deprecated.
-
onTermination
void onTermination(scala.PartialFunction<PersistentFSM.StopEvent<S,D>,scala.runtime.BoxedUnit> terminationHandler)
Deprecated.
-
onTransition
void onTransition(scala.PartialFunction<scala.Tuple2<S,S>,scala.runtime.BoxedUnit> transitionHandler)
Deprecated.
-
postStop
void postStop() throws java.lang.Exception
Deprecated.Description copied from interface:Actor
User overridable callback. Is called asynchronously after 'actor.stop()' is invoked. Empty default implementation.
-
processEvent
void processEvent(PersistentFSM.Event<D> event, java.lang.Object source)
Deprecated.
-
processMsg
void processMsg(java.lang.Object value, java.lang.Object source)
Deprecated.
-
receive
scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit> receive()
Deprecated.Description copied from interface:Actor
Scala API: This defines the initial actor behavior, it must return a partial function with the actor logic.
-
register
void register(S name, scala.PartialFunction<PersistentFSM.Event<D>,PersistentFSM.State<S,D,E>> function, scala.Option<scala.concurrent.duration.FiniteDuration> timeout)
Deprecated.
-
setStateTimeout
void setStateTimeout(S state, scala.Option<scala.concurrent.duration.FiniteDuration> timeout)
Deprecated.
-
setTimer
void setTimer(java.lang.String name, java.lang.Object msg, scala.concurrent.duration.FiniteDuration timeout, boolean repeat)
Deprecated.Use startSingleTimer, startTimerWithFixedDelay or startTimerAtFixedRate instead. This has the same semantics as startTimerAtFixedRate, but startTimerWithFixedDelay is often preferred. Since 2.6.0.
-
setTimer$default$4
boolean setTimer$default$4()
Deprecated.
-
startSingleTimer
void startSingleTimer(java.lang.String name, java.lang.Object msg, scala.concurrent.duration.FiniteDuration delay)
Deprecated.
-
startTimer
void startTimer(java.lang.String name, java.lang.Object msg, scala.concurrent.duration.FiniteDuration timeout, PersistentFSM.TimerMode mode)
Deprecated.
-
startTimerAtFixedRate
void startTimerAtFixedRate(java.lang.String name, java.lang.Object msg, scala.concurrent.duration.FiniteDuration interval)
Deprecated.
-
startTimerWithFixedDelay
void startTimerWithFixedDelay(java.lang.String name, java.lang.Object msg, scala.concurrent.duration.FiniteDuration delay)
Deprecated.
-
startWith
void startWith(S stateName, D stateData, scala.Option<scala.concurrent.duration.FiniteDuration> timeout)
Deprecated.Set initial state. Call this method from the constructor before theinitialize()
method. If different state is needed after a restart this method, followed byinitialize()
, can be used in the actor life cycle hooksActor.preStart()
andActor.postRestart(java.lang.Throwable)
.- Parameters:
stateName
- initial state designatorstateData
- initial state datatimeout
- state timeout for the initial state, overriding the default timeout for that state
-
startWith$default$3
scala.Option<scala.concurrent.duration.FiniteDuration> startWith$default$3()
Deprecated.
-
stateData
D stateData()
Deprecated.
-
stateName
S stateName()
Deprecated.
-
stateNames
scala.collection.Iterable<S> stateNames()
Deprecated.
-
stay
PersistentFSM.State<S,D,E> stay()
Deprecated.Produce "empty" transition descriptor. Return this from a state function when no state change is to be effected.No transition event will be triggered by
stay()
. If you want to trigger an event likeS -> S
foronTransition
to handle usegoto
instead.- Returns:
- descriptor for staying in current state
-
stop
PersistentFSM.State<S,D,E> stop()
Deprecated.Produce change descriptor to stop this FSM actor with reason "Normal".
-
stop
PersistentFSM.State<S,D,E> stop(PersistentFSM.Reason reason)
Deprecated.Produce change descriptor to stop this FSM actor including specified reason.
-
stop
PersistentFSM.State<S,D,E> stop(PersistentFSM.Reason reason, D stateData)
Deprecated.Produce change descriptor to stop this FSM actor including specified reason.
-
super$postStop
void super$postStop()
Deprecated.CallonTermination
hook; if you want to retain this behavior when overriding make sure to callsuper.postStop()
.Please note that this method is called by default from
preRestart()
, so override that one ifonTermination
shall not be called during restart.
-
terminate
void terminate(PersistentFSM.State<S,D,E> nextState)
Deprecated.
-
terminateEvent_$eq
void terminateEvent_$eq(scala.PartialFunction<PersistentFSM.StopEvent<S,D>,scala.runtime.BoxedUnit> x$1)
Deprecated.
-
timeoutFuture_$eq
void timeoutFuture_$eq(scala.Option<Cancellable> x$1)
Deprecated.
-
total2pf
scala.PartialFunction<scala.Tuple2<S,S>,scala.runtime.BoxedUnit> total2pf(scala.Function2<S,S,scala.runtime.BoxedUnit> transitionHandler)
Deprecated.
-
transform
PersistentFSMBase.TransformHelper transform(scala.PartialFunction<PersistentFSM.Event<D>,PersistentFSM.State<S,D,E>> func)
Deprecated.
-
transitionEvent_$eq
void transitionEvent_$eq(scala.collection.immutable.List<scala.PartialFunction<scala.Tuple2<S,S>,scala.runtime.BoxedUnit>> x$1)
Deprecated.
-
when
void when(S stateName, scala.concurrent.duration.FiniteDuration stateTimeout, scala.PartialFunction<PersistentFSM.Event<D>,PersistentFSM.State<S,D,E>> stateFunction)
Deprecated.Insert a new StateFunction at the end of the processing chain for the given state. If the stateTimeout parameter is set, entering this state without a differing explicit timeout setting will trigger a StateTimeout event; the same is true when using #stay.- Parameters:
stateName
- designator for the statestateTimeout
- default state timeout for this statestateFunction
- partial function describing response to input
-
when$default$2
scala.concurrent.duration.FiniteDuration when$default$2()
Deprecated.
-
whenUnhandled
void whenUnhandled(scala.PartialFunction<PersistentFSM.Event<D>,PersistentFSM.State<S,D,E>> stateFunction)
Deprecated.
-
-