finitestate

package
v0.0.18 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StatusNew       = transitions.StatusNew
	StatusBooting   = transitions.StatusBooting
	StatusRunning   = transitions.StatusRunning
	StatusReloading = transitions.StatusReloading
	StatusStopping  = transitions.StatusStopping
	StatusStopped   = transitions.StatusStopped
	StatusError     = transitions.StatusError
	StatusUnknown   = transitions.StatusUnknown
)

Variables

View Source
var TypicalTransitions = transitions.Typical

TypicalTransitions is a set of standard transitions for a finite state machine.

Functions

This section is empty.

Types

type Machine

type Machine struct {
	*fsm.Machine
	// contains filtered or unexported fields
}

Machine is a wrapper around go-fsm v2 that provides the v1 API compatibility. It manages both the FSM and broadcast functionality.

func New

func New(handler slog.Handler) (*Machine, error)

New creates a new finite state machine with the specified logger using "standard" state transitions. This function provides compatibility with the v1 API while using v2 under the hood.

func (*Machine) GetStateChan

func (s *Machine) GetStateChan(ctx context.Context) <-chan string

GetStateChan returns a channel that emits the state whenever it changes. The channel is closed when the provided context is canceled. For v1 API compatibility, the current state is sent immediately to the channel. A 5-second broadcast timeout is used to prevent slow consumers from blocking state updates.

Jump to

Keyboard shortcuts

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