This PR adds the MinimalActorContext to the FSM StateManager. Allows the creation of child actors and send messages to self in an FSM.
Changes:
Exposed the MinimalActorContext in the FSM StateManager.
Removed the ActorSystem from the MinimalActorContext as we want to restrict access to the scheduler in the FSMBuilder. Access to the Actor Scheduler would allow someone to transition states in the scheduleOnce functions.
Switched the FaultHandler to use the ActorContext instead of the Minimal one since it requires access to the ActorSystem. Switched the Request and Response types to be wildcards since the FaultHandler should never actually make use of them. Before they were allowed to be [... , Nothing, Any] due to the MinimalActorContext allowing co/contra variance, however, the ActorContext only allows for invariance.
Usage of the FSM ActorContext:
FSM[IO, FsmParentState, Int, FsmRequest, Any]
.when(FsmIdle) {
case (Event(FsmRun, _), sM) =>
for {
fsmChildActor <- sM.minimalContext.actorOf(FsmChild())
result <- fsmChildActor ? FsmChildEcho
state <- sM.goto(FsmRunning).replying(result)
} yield state
}
.when(FsmRunning) {
case (Event(FsmRun, _), sM) =>
(sM.minimalContext.self ! FsmStop) *> sM.stay()
case (Event(FsmStop, _), sM) =>
stopped.complete(true) *> sM.stay()
}
.withConfig(FSMConfig.withConsoleInformation)
.startWith(startWith, 0)
.initialize
Summary
This PR adds the MinimalActorContext to the FSM StateManager. Allows the creation of child actors and send messages to self in an FSM.
Changes:
Usage of the FSM ActorContext: