Documentation ¶
Overview ¶
Package helpers is a set of useful functions when working with state machines.
Index ¶
- func Add1AsyncBlock(ctx context.Context, mach types.MachineApi, waitState string, addState string, ...) am.Result
- func Add1Block(ctx context.Context, mach types.MachineApi, state string, args am.A) am.Result
- func IndexesToStates(mach types.MachineApi, indexes []int) am.S
- func IsMulti(mach types.MachineApi, state string) bool
- func MachDebug(mach *am.Machine, amDbgAddr string, logLvl am.LogLevel, stdout bool)
- func MachDebugEnv(mach *am.Machine, stdout bool)
- func MachDebugT(t *testing.T, mach *am.Machine, amDbgAddr string, logLvl am.LogLevel, ...)
- func StatesToIndexes(mach types.MachineApi, states am.S) []int
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Add1AsyncBlock ¶
func Add1AsyncBlock( ctx context.Context, mach types.MachineApi, waitState string, addState string, args am.A, ) am.Result
Add1AsyncBlock adds a state from an async op and waits for another one from the op to become active. Theoretically, it should work with any state pair, including Multi states.
func Add1Block ¶
Add1Block activates a state and waits until it becomes active. If it's a multi state, it also waits for it te de-activate. Returns early if a non-multi state is already active. Useful to avoid the queue.
func IndexesToStates ¶
func IndexesToStates(mach types.MachineApi, indexes []int) am.S
IndexesToStates converts a list of state indexes to a list of state names, for a given machine.
func IsMulti ¶
func IsMulti(mach types.MachineApi, state string) bool
IsMulti returns true if a state is a multi state.
func MachDebug ¶
MachDebug sets up a machine for debugging, based on the AM_DEBUG env var, passed am-dbg address, log level and stdout flag.
func MachDebugEnv ¶
MachDebugEnv sets up a machine for debugging, based on env vars only.
func MachDebugT ¶
func MachDebugT(t *testing.T, mach *am.Machine, amDbgAddr string, logLvl am.LogLevel, stdout bool, )
MachDebugT sets up a machine for debugging in tests, based on the AM_DEBUG env var, passed am-dbg address, log level and stdout flag.
func StatesToIndexes ¶
func StatesToIndexes(mach types.MachineApi, states am.S) []int
StatesToIndexes converts a list of state names to a list of state indexes, for a given machine.
Types ¶
This section is empty.