state

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Creating = "creating"
	Active   = "active"
	Inactive = "inactive"
	Deleting = "deleting"
	Failed   = "failed"
)

Shared resource lifecycle states. Domain-specific state machines add only states that do not describe a general resource lifecycle.

Variables

This section is empty.

Functions

This section is empty.

Types

type Edge

type Edge string

Edge represents a state transition edge. The transition must be a string with an arrow, for example "requested -> approved".

func (Edge) Value

func (e Edge) Value() ([]string, string)

Value parses the edge and returns a source and destination pair.

type Machine

type Machine map[string]Edge

Machine represents a finite state machine keyed by action name.

func (Machine) CanTransition

func (m Machine) CanTransition(from, to string) bool

CanTransition reports whether a transition from one state to another is allowed.

func (Machine) Default

func (m Machine) Default() string

Default returns the default state. If no default state was configured it returns an empty string.

func (Machine) States

func (m Machine) States() []string

States returns a list of all possible states in the machine.

func (Machine) TryAction

func (m Machine) TryAction(action, current string) (string, bool)

TryAction attempts to transition from a current state.

Jump to

Keyboard shortcuts

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