fsm

package
v0.0.0-...-53bcd79 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 2, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnrecognizedState = xerrors.Define("unrecognized state")
)

Functions

func DotOutput

func DotOutput(w io.Writer, dir string) error

Types

type FSM

type FSM struct {
	// CloseContext allows to specify the context when entering the close state.
	// If not specify CloseContext, then entering the close state will be used same context.
	CloseContext func() (context.Context, context.CancelFunc)
	// DisableErrorOutput allows to disable writing the error to stderr.
	DisableErrorOutput bool
	// contains filtered or unexported fields
}

func NewFSM

func NewFSM(funcs map[State]StateFunc, initState, closeState State) *FSM

func (*FSM) Loop

func (f *FSM) Loop() error

func (*FSM) LoopContext

func (f *FSM) LoopContext(ctx context.Context) error

func (*FSM) Shutdown

func (f *FSM) Shutdown()

func (*FSM) SignalHandling

func (f *FSM) SignalHandling(signals ...os.Signal)

SignalHandling handles specifying signal. Deprecated.

type State

type State int
const (
	UnknownState State = -255
	WaitState    State = -254
	CloseState   State = -253
)

func Error

func Error(err error) (State, error)

func Finish

func Finish() (State, error)

func Next

func Next(state State) (State, error)

func Wait

func Wait() (State, error)

type StateFunc

type StateFunc func(context.Context) (State, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL