Documentation
¶
Index ¶
- Constants
- type Manager
- func (m *Manager) EnterMaintenance(ttl time.Duration) error
- func (m *Manager) IsAvailable() bool
- func (m *Manager) IsInMaintenance() bool
- func (m *Manager) IsMaintenanceExpired() bool
- func (m *Manager) MaintenanceTTL() time.Time
- func (m *Manager) OnStateChange(cb StateChangeCallback)
- func (m *Manager) Snapshot() (state State, ttl time.Time)
- func (m *Manager) State() State
- func (m *Manager) StateEnteredAt() time.Time
- func (m *Manager) TransitionTo(newState State) error
- type State
- type StateChangeCallback
Constants ¶
const MaxMaintenanceTTL = 15 * time.Minute
MaxMaintenanceTTL is the maximum duration a node can remain in maintenance mode. The leader's health monitor enforces this limit — nodes that exceed it are treated as unreachable so they can't hide in maintenance forever.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager manages a node's lifecycle state machine. It has no external dependencies (no LibP2P, no discovery imports) and is fully testable in isolation.
func NewManager ¶
func NewManager() *Manager
NewManager creates a new lifecycle manager in the joining state.
func (*Manager) EnterMaintenance ¶
EnterMaintenance transitions to maintenance with a TTL. The TTL is capped at MaxMaintenanceTTL.
func (*Manager) IsAvailable ¶
IsAvailable returns true if the node is in a state that can serve requests.
func (*Manager) IsInMaintenance ¶
IsInMaintenance returns true if the node is in maintenance mode.
func (*Manager) IsMaintenanceExpired ¶
IsMaintenanceExpired returns true if the node is in maintenance and the TTL has expired. Used by the leader's health monitor to enforce the max TTL.
func (*Manager) MaintenanceTTL ¶
MaintenanceTTL returns the maintenance mode expiration time. Returns zero value if not in maintenance.
func (*Manager) OnStateChange ¶
func (m *Manager) OnStateChange(cb StateChangeCallback)
OnStateChange registers a callback invoked on state transitions. Callbacks are called with the lock released to avoid deadlocks.
func (*Manager) Snapshot ¶
Snapshot returns a point-in-time copy of the lifecycle state for embedding in metadata without holding the lock.
func (*Manager) StateEnteredAt ¶
StateEnteredAt returns when the current state was entered.
func (*Manager) TransitionTo ¶
TransitionTo moves the node to a new lifecycle state. Returns an error if the transition is not valid.
type StateChangeCallback ¶
type StateChangeCallback func(old, new State)
StateChangeCallback is called when the lifecycle state changes.