Documentation
¶
Index ¶
- type State
- type StateManager
- func (sm *StateManager) GetState(stateType StateType) State
- func (sm *StateManager) SetState(stateType StateType, state State)
- func (sm *StateManager) WaitForState(stateType StateType, desiredState State, timeout time.Duration) error
- func (sm *StateManager) WaitForStates(stateType StateType, desiredStates []State, timeout time.Duration) error
- type StateType
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.
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.