state

package
v0.0.0-...-da72ffe Latest Latest
Warning

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

Go to latest
Published: May 16, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type State

type State int

State represents the current state of a particular node component type.

const (
	Uninitialized State = iota // The service has not been initialized yet.
	Initializing               // The service is currently in the process of initialization.
	Initialized                // The service has been successfully initialized.
	Starting                   // The service is in the process of starting.
	Started                    // The service has started successfully and is running.
	Produced                   // A block has been produced.
	Failed                     // The service failed to initialize or start.
	Stopping
	Stopped // The service has been stopped.
	Idle    // The service itself or processing component (such as block producer) is in idle state.
	Ready
	Completed
	Running
	ChainSyncing
	ChainSynced
)

Define various states a service or component can be in.

const (
	PhaseCommitment State = iota + 100 // Adding offset to avoid conflicts and give buffer
	PhaseShareDistribution
	PhaseLeaderElection
	PhaseCompleted
)

func (State) String

func (s State) String() string

String returns a string representation of the service state.

type StateManager

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

StateManager manages and tracks the state of services or components.

func NewManager

func NewManager(logger logger.Logger, obs *observability.Observability) (*StateManager, error)

NewManager creates a new StateManager instance with the provided logger and observability.

func (*StateManager) GetState

func (sm *StateManager) GetState(stateType StateType) State

GetState retrieves the current state of a specified service or component.

func (*StateManager) SetState

func (sm *StateManager) SetState(stateType StateType, state State)

SetState updates the state of a service or component, logs the change, and emits a metric if applicable.

func (*StateManager) WaitForState

func (sm *StateManager) WaitForState(stateType StateType, desiredState State, timeout time.Duration) error

WaitForState waits for a service or component to reach a desired state within a given timeout period. Returns an error if the timeout expires before the desired state is reached.

func (*StateManager) WaitForStates

func (sm *StateManager) WaitForStates(stateType StateType, desiredStates []State, timeout time.Duration) error

type StateType

type StateType string

StateType represents a type of service or component state that the StateManager tracks.

const (
	ServerStateType StateType = "server"
)

Define service and component state types.

func (StateType) String

func (s StateType) String() string

Jump to

Keyboard shortcuts

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