The FsmActor
(finite state machine actor) is a Coral Actor that keeps state that can be changed due to trigger events.
The FsmActor has "type": "fsm"
. The params
value is a JSON object with the following fields:
field | type | required | description |
---|---|---|---|
key |
string | yes | the name of the field in the trigger-JSON that can affect the state |
table |
map | yes | a map of maps of state transitions |
s0 |
string | yes | the initial state |
Note that the initial state s0 must be a valid key in the table.
The FsmActor
only does useful work if the trigger is connected.
The actor checks for the key field and changes state if appropriate.
Taking the example constructor above, the initial state is normal
. Now if a trigger JSON contains "transactionsize": "x-large"
then the state will change to suspicious
.
Another trigger with the same "transactionsize": "x-large"
will now change to state to alarm
.
The FsmActor
emits nothing, the state must be queried using a collect through another actor.
The FsmActor
keeps the FSM state in a map as coral actor state:
field | type | description |
---|---|---|
s |
string | the (FSM) state label |
The state is updated according to the table due to trigger events.
The FsmActor
does not collect state from other actors.
The FsmActor
does not provide timer actions.