Open thedrow opened 3 years ago
@thedrow
The crashed state is currently not in use, it is pending the completion of pytransitions/transitions#485 or another solution.
At the time of this comment, you have that unchecked, but it looks like the issue is resolved. Is crashed
in use or intended to be in use?
We need to use the new on_exception
hook instead of rolling our own implementation.
State Machine
I defined an hierarchical state machine to model the lifecycle of the actor. Other states and transitions between them may be added in the future.
The transitions library allows you to append callbacks to the different events of the state machine. Please refer to their documentation if you'd like to find out which callbacks are available and their order of execution.
The following diagram defines the fundamental actor states and how to transition between them:![Actor Lifecycle State Machine](https://user-images.githubusercontent.com/48936/107506089-43225a00-6ba6-11eb-810e-0ac14bf0e1e9.png)
States
The state machine has states which define where the actor is during his lifecycle.
The following tables describes all current states:
Actor State Machine
initializing
initialized
starting
actor.start()
starting -> dependencies_started
starting -> resources_acquired
starting -> tasks_started
started
started -> running
started -> paused
started -> running -> healthy
started -> running -> degraded
started -> running -> unhealthy
stopping
actor.stop()
stopping -> tasks_stopped
stopping -> resources_released
stopping -> dependencies_stopped
stopped
crashed
Actor Restart State Machine
ignore
restarting
restarting -> stopping
restarting -> starting
restarted
TODOs
Triggers
Triggers are the API the state machine exposes to trigger a transition between states.
initialize()
start()
pause()
resume()
stop()
restart()
report_error()
report_warning()
report_problem()
recover()
Transitions
The after transition callback allows us to progress the state machine until the desired state by repeatedly calling the
start()
orstop()
triggers until the desired state is reached. We use the before transition callbacks to manage the lifecycle of the actor.starting
starting -> dependencies_started
started
statestarting -> dependencies_started
starting -> resources_acquired
starting -> resources_acquired
starting -> tasks_started
stopping -> tasked_stopped
stopping -> resources_released
stopping -> resources_released
stopping -> dependencies_stopped
stopped
stateThe rest of the transitions have no use currently other than stepping into the next step. In the future we will introduce a public API to let the users use them.
TODOs
stopped
andstarting
requires test coverage - #11.crashed
andstarting
using thestart()
trigger.