fsm

package
v0.5.0-beta Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2023 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event struct {
	Type    string
	Status  string
	Message string
	Obj     Stateful
}

type FSM

type FSM struct {
	// contains filtered or unexported fields
}

func New

func New(option Option) *FSM

func (*FSM) Do

func (m *FSM) Do(handler Handler) *FSM

func (*FSM) Event

func (m *FSM) Event(event Event) error

func (*FSM) From

func (m *FSM) From(statues []string) *FSM

func (*FSM) To

func (m *FSM) To(status string) *FSM

func (*FSM) When

func (m *FSM) When(event string) *FSM

type Handler

type Handler func(obj Event) error

type Option

type Option struct {
	Obj    Stateful
	Logger *zap.SugaredLogger
}

type Stateful

type Stateful interface {
	GetStatus() string
	SetStatus(status string)
	GetMessage() string
	SetMessage(msg string)
}

Jump to

Keyboard shortcuts

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