Documentation
¶
Overview ¶
Package fsm is what every merilo machine imports: the outcome Fire returns, the error a holder reports for a refused event, and the bounded counter a machine keeps instead of a raw integer. A machine declares only its own states, events, actions and transitions.
fsm imports nothing, allocates nothing and never panics.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Counter ¶
type Counter struct {
// contains filtered or unexported fields
}
Counter is a count from zero to a limit fixed when it is built. It never passes either end: Inc refuses at the limit and Dec at zero. It is a comparable value, so a machine holding one stays comparable.
func NewCounter ¶
NewCounter returns a counter at zero that counts up to limit. A negative limit counts nothing.
type Outcome ¶
type Outcome int64
Outcome reports what Fire did with an event.
const ( Moved Outcome // the event took effect: the machine changed, or its actions say what to do Ignored // nothing to do; the machine is unchanged Rejected // the event is not allowed now; the machine is unchanged Invalid // an impossible state or event, refused with the machine unchanged )
Outcome values. The zero value is an unexported sentinel, so an outcome that was never set matches no case.