Documentation
¶
Overview ¶
Package reconciler provides infrastructure state reconciliation driven by event queue processing.
Package reconciler handles instance lifecycle management: scaling managed groups to desired size, detecting and replacing unhealthy instances, coordinating graceful drains, and expiring old instances. It processes events from a queue and only acts when the server is the shard leader.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewPermanentError ¶
NewPermanentError wraps an error as non-retryable
Types ¶
type EventType ¶
type EventType string
EventType represents the type of reconciliation event
const ( EventCheckInstance EventType = "CheckInstance" // e.g. on gRPC disconnect or missed health report EventGroupChanged EventType = "GroupChanged" EventInstanceDeleted EventType = "InstanceDeleted" EventDrainAcked EventType = "DrainAcked" // Operator acknowledged drain complete EventTerminationNotice EventType = "TerminationNotice" // Instance termination notice received EventInitialReconcile EventType = "InitialReconcile" )
type InstanceManager ¶
type InstanceManager interface {
CreateInstance(ctx context.Context, req instances.CreateInstanceRequest) (*instances.CreateInstanceResponse, error)
DeleteInstance(ctx context.Context, instanceID string) error
}
InstanceManager defines the interface for instance management operations required by the reconciler
type Options ¶
type Options struct {
InstanceManager InstanceManager
ConfigLoader *config.Loader
LocalDB *localdb.DB
Provider infra.Provider
NotifyDrain func(instanceID, group, reason string, unhealthyAt, deleteAt time.Time)
NotifyError func(group, instanceID, errMsg string)
IsLeader func() bool
CreateRateLimit time.Duration
Logger *slog.Logger
}
Options contains options for creating a Reconciler
type PermanentError ¶
type PermanentError struct {
Err error
}
PermanentError wraps an error to indicate it should not be retried
func (*PermanentError) Error ¶
func (e *PermanentError) Error() string
func (*PermanentError) Unwrap ¶
func (e *PermanentError) Unwrap() error
type ReconcileEvent ¶
type ReconcileEvent struct {
Type EventType
Tenant string
GroupKey string
InstanceID string
Timestamp time.Time
PreventDuplicate bool // Skip if same event recently processed
Cause string // Why this event was triggered (e.g. "disconnect")
Attempt int // Retry attempt number for follow-up polling
}
ReconcileEvent represents an event that triggers reconciliation
type Reconciler ¶
type Reconciler struct {
// contains filtered or unexported fields
}
Reconciler handles instance reconciliation (matching actual instance count to desired group size)
func (*Reconciler) Enqueue ¶
func (r *Reconciler) Enqueue(event ReconcileEvent)
Enqueue adds a reconciliation event to the queue