stateflow

package
v2.0.0-alpha.2 Latest Latest
Warning

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

Go to latest
Published: May 11, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package stateflow provides a finite state machine for managing resource lifecycle operations. It implements state transitions triggered by events with associated commands.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AppStateCommand

type AppStateCommand func(replica *inapi.AppReplicaInstance) (string, error)

AppStateCommand defines the function signature for app state operations

type AppStateEntry

type AppStateEntry struct {
	State   string          // target state after transition
	Command AppStateCommand // command to execute during transition
}

AppStateEntry represents a state transition with its associated command

type AppStateWorkflow

type AppStateWorkflow struct {

	// Transitions maps: current state -> event -> next state command
	Transitions map[string]map[string]*AppStateEntry
	// contains filtered or unexported fields
}

AppStateWorkflow manages state transitions for app operations It implements a finite state machine where transitions are triggered by events

func (*AppStateWorkflow) NextCommand

func (it *AppStateWorkflow) NextCommand(state, event string) (*AppStateEntry, bool)

NextCommand returns the command for a given state and event transition Returns false if no transition is defined for the state/event pair

func (*AppStateWorkflow) Register

func (it *AppStateWorkflow) Register(
	currentState, event, nextState string,
	nextCommand AppStateCommand,
)

Register adds a new state transition to the workflow currentState: the state from which the transition applies event: the event that triggers the transition nextState: the target state after the transition nextCommand: the command to execute during the transition

Jump to

Keyboard shortcuts

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