The FsmActor
(finite state machine actor) is a Coral Actor that keeps state that can be changed due to trigger events.
The creation JSON of the FSM actor (see Coral Actor) has "type": "fsm"
.
The params
value is a JSON 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 |
{
"data": {
"type": "actors",
"attributes": {
"type": "fsm",
"params": {
"key": "transactionsize",
"table": {
"normal": {
"small": "normal",
"large": "normal",
"x-large": "suspicious"
},
"suspicious": {
"small": "normal",
"large": "suspicious",
"x-large": "alarm"
},
"alarm":{
"small": "suspicious",
"large": "alarm",
"x-large": "alarm"
}
},
"s0": "normal"
}
}
}
}
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. Only the state provides information.
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.