Documentation
¶
Overview ¶
Package failover provides primary/standby resource groups with manual and health-based failover policy skeletons. Failback is always a separate workflow.
Index ¶
- Constants
- Variables
- type Decision
- type Group
- type GroupConfig
- type Manager
- func (m *Manager) EvaluateHealth(ctx context.Context, name string) (resource.ResourceID, bool, error)
- func (m *Manager) ExecuteFailback(ctx context.Context, name, reason string) (Decision, error)
- func (m *Manager) ExecuteFailover(ctx context.Context, name, reason string, target *resource.ResourceID) (Decision, error)
- func (m *Manager) Get(name string) (Group, error)
- func (m *Manager) History() []Decision
- func (m *Manager) List() []Group
- func (m *Manager) Register(cfg GroupConfig) error
- type Policy
Constants ¶
const DefaultMaxHistory = 256
DefaultMaxHistory bounds decision history.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type Decision ¶
type Decision struct {
Group string
From resource.ResourceID
To resource.ResourceID
Reason string
At time.Time
EpochAdv resource.EpochAdvance
Failback bool
}
Decision records a failover or failback.
type Group ¶
type Group struct {
Name string
Policy Policy
Primary resource.ResourceID
Standbys []resource.ResourceID
Active resource.ResourceID
Epoch resource.ResourceEpoch
}
Group is a primary/standby set.
type GroupConfig ¶
type GroupConfig struct {
Name string
Primary resource.ResourceID
Standbys []resource.ResourceID
Policy Policy
}
GroupConfig configures a failover group.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager owns failover groups and advances resource epochs via a registry.
func NewManager ¶
NewManager creates a failover manager.
func (*Manager) EvaluateHealth ¶
func (m *Manager) EvaluateHealth(ctx context.Context, name string) (resource.ResourceID, bool, error)
EvaluateHealth is a health-based policy skeleton: returns a recommended standby when the active resource is unhealthy. Does not execute failover.
func (*Manager) ExecuteFailback ¶
ExecuteFailback is a separate controlled workflow back toward the configured primary. It never runs automatically from health policy.
func (*Manager) ExecuteFailover ¶
func (m *Manager) ExecuteFailover(ctx context.Context, name, reason string, target *resource.ResourceID) (Decision, error)
ExecuteFailover promotes a standby (manual or health-based). Advances the newly active resource epoch in the registry.
func (*Manager) Register ¶
func (m *Manager) Register(cfg GroupConfig) error
Register adds a failover group.