Documentation ¶
Index ¶
- Constants
- Variables
- func GetDstState(ctx context.Context) string
- func GetSrcState(ctx context.Context) string
- type DispatchError
- type Dispatcher
- type FSM
- func (e *FSM) AsyncDispatch(ctx context.Context, next string) (chan error, context.CancelFunc)
- func (e *FSM) Collect(ch chan<- prometheus.Metric)
- func (e *FSM) Describe(ch chan<- *prometheus.Desc)
- func (e *FSM) Dispatch(ctx context.Context, next string) error
- func (e *FSM) SetName(name string)
- func (e *FSM) SetState(newState string)
- func (e *FSM) Size() uint64
- func (e *FSM) State() string
- func (e *FSM) Stop()
- type Procedure
- type Stack
- type StackKey
Constants ¶
View Source
const UnknownState = ""
UnknownState it is value is an undefined state.
Variables ¶
View Source
var ( // ErrNotInitalState is the error returned by Machine when the is // not have initial state of Machine. ErrNotInitalState = errors.New("Is not set initial value of state") // ErrCtxCanceled is the error when context is canceled. ErrCtxCanceled = errors.New("Context canceled") // ErrNotRegTransition is the error returned by Machine from Dispatch method when the is // have not rules for current transition (src->dst not have actions). ErrNotRegTransition = errors.New("Not registred transition") )
View Source
var DefaultToDispatchCap = 8
DefaultToDispatchCap default capacity of channel for new instance FSM.
NOTE: set this value depending on your needs.
Functions ¶
func GetDstState ¶
GetDstState returns destinate state from context.
func GetSrcState ¶
GetSrcState returns source state from context.
Types ¶
type DispatchError ¶
type DispatchError struct { ActionName string SrcState string DstState string Err error IsPanic bool PanicStackRuntime string }
DispatchError is the container with custom errors for dispatcher.
func (DispatchError) Error ¶
func (e DispatchError) Error() string
type Dispatcher ¶ added in v1.1.0
Dispatcher dispatcher of finite state machine.
type FSM ¶ added in v1.1.0
type FSM struct {
// contains filtered or unexported fields
}
FSM finite state machine.
func (*FSM) AsyncDispatch ¶ added in v1.2.0
AsyncDispatch dispatcher of finite state machine (thread-safe). Returns the channel for feedback and the function of cancel of transition context.
func (*FSM) Collect ¶ added in v1.1.0
func (e *FSM) Collect(ch chan<- prometheus.Metric)
func (*FSM) Describe ¶ added in v1.1.0
func (e *FSM) Describe(ch chan<- *prometheus.Desc)
Click to show internal directories.
Click to hide internal directories.