Documentation
¶
Overview ¶
Package lifecycle provides a configurable state machine for AWS resource lifecycle transitions. Resources progress through a sequence of states (e.g., CREATING → AVAILABLE → DELETING → DELETED) either instantly or with configurable delays to simulate real AWS async behavior.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Config controls whether lifecycle delays are simulated or instant.
func DefaultConfig ¶
func DefaultConfig() *Config
DefaultConfig returns a Config with delays disabled (instant transitions).
func (*Config) EffectiveDelay ¶
EffectiveDelay returns the actual delay to use for a given nominal delay. Returns 0 if delays are disabled.
func (*Config) SetEnabled ¶
SetEnabled enables or disables simulated delays globally.
func (*Config) SetSpeedFactor ¶
SetSpeedFactor sets a multiplier for all delays (e.g., 0.1 = 10x faster).
type Machine ¶
type Machine struct {
// contains filtered or unexported fields
}
Machine manages the lifecycle of a single resource through a defined set of state transitions.
func NewMachine ¶
func NewMachine(initialState State, transitions []Transition, cfg *Config) *Machine
NewMachine creates a lifecycle machine starting at initialState. transitions maps each state to its next automatic transition.
func (*Machine) ForceState ¶
ForceState immediately sets the state, bypassing transitions. Use for external triggers (e.g., user-initiated delete).
func (*Machine) History ¶
func (m *Machine) History() []StateRecord
History returns all state transitions in order.
func (*Machine) OnTransition ¶
OnTransition sets a callback invoked after each automatic transition.
type State ¶
type State string
State represents a resource lifecycle state (e.g., "CREATING", "AVAILABLE").
type StateRecord ¶
StateRecord captures a historical state change.