Documentation
¶
Overview ¶
Package deployer implements the Deployer component that deploys validated HAProxy configurations to discovered HAProxy pod endpoints.
The Deployer is a stateless executor that receives DeploymentScheduledEvent and executes deployments to the specified endpoints. All deployment scheduling, rate limiting, and queueing logic is handled by the DeploymentScheduler component.
Package deployer implements deployment scheduling and execution components.
Package deployer implements deployment scheduling and execution components.
Index ¶
Constants ¶
const ( // ComponentName is the unique identifier for this component. ComponentName = "deployer" // EventBufferSize is the size of the event subscription buffer. // Size 50: Low-volume component (~1-2 deployment events per reconciliation cycle). // Larger buffers reduce event drops during bursts but consume more memory. EventBufferSize = 50 )
const ( // DriftMonitorComponentName is the unique identifier for the drift prevention monitor component. DriftMonitorComponentName = "drift-monitor" // DriftMonitorEventBufferSize is the size of the event subscription buffer for the drift monitor. DriftMonitorEventBufferSize = 50 )
const ( // SchedulerComponentName is the unique identifier for the DeploymentScheduler component. SchedulerComponentName = "deployment-scheduler" // SchedulerEventBufferSize is the size of the event subscription buffer for the scheduler. // Size 50: Moderate-volume component handling template, validation, and discovery events. // Note: Named with "Scheduler" prefix to avoid conflict with EventBufferSize in this package. SchedulerEventBufferSize = 50 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Component ¶
type Component struct {
// contains filtered or unexported fields
}
Component implements the deployer component.
It subscribes to DeploymentScheduledEvent and deploys configurations to HAProxy instances. This is a stateless executor - all scheduling logic is handled by the DeploymentScheduler component.
Event subscriptions:
- DeploymentScheduledEvent: Execute deployment to specified endpoints
The component publishes deployment result events for observability.
func New ¶
New creates a new Deployer component.
Parameters:
- eventBus: The EventBus for subscribing to events and publishing results
- logger: Structured logger for component logging
Returns:
- A new Component instance ready to be started
func (*Component) HealthCheck ¶
HealthCheck implements the lifecycle.HealthChecker interface. Returns an error if the component appears to be stalled (processing for > timeout). Returns nil when idle (not processing) - idle is always healthy for event-driven components.
func (*Component) Name ¶
Name returns the unique identifier for this component. Implements the lifecycle.Component interface.
func (*Component) Start ¶
Start begins the deployer's event loop.
This method blocks until the context is cancelled or an error occurs. It processes events from the subscription channel established in the constructor.
Parameters:
- ctx: Context for cancellation and lifecycle management
Returns:
- nil when context is cancelled (graceful shutdown)
- Error only in exceptional circumstances
type DeploymentScheduler ¶
type DeploymentScheduler struct {
// contains filtered or unexported fields
}
DeploymentScheduler implements deployment scheduling with rate limiting.
It subscribes to events that trigger deployments, maintains the state of rendered and validated configurations, and enforces minimum deployment intervals.
Event subscriptions:
- TemplateRenderedEvent: Track rendered config and auxiliary files
- ValidationCompletedEvent: Cache validated config and schedule deployment
- ValidationFailedEvent: Deploy cached config for drift prevention fallback
- HAProxyPodsDiscoveredEvent: Update endpoints and schedule deployment
The component publishes DeploymentScheduledEvent when a deployment should execute.
func NewDeploymentScheduler ¶
func NewDeploymentScheduler(eventBus *busevents.EventBus, logger *slog.Logger, minDeploymentInterval, deploymentTimeout time.Duration) *DeploymentScheduler
NewDeploymentScheduler creates a new DeploymentScheduler component.
Parameters:
- eventBus: The EventBus for subscribing to events and publishing scheduled deployments
- logger: Structured logger for component logging
- minDeploymentInterval: Minimum time between consecutive deployments (rate limiting)
- deploymentTimeout: Maximum time to wait for a deployment to complete before retrying
Returns:
- A new DeploymentScheduler instance ready to be started
func (*DeploymentScheduler) HealthCheck ¶
func (s *DeploymentScheduler) HealthCheck() error
HealthCheck implements the lifecycle.HealthChecker interface. Returns an error if the component appears to be stalled (processing for > timeout). Returns nil when idle (not processing) - idle is always healthy for event-driven components.
func (*DeploymentScheduler) Name ¶
func (s *DeploymentScheduler) Name() string
Name returns the unique identifier for this component. Implements the lifecycle.Component interface.
func (*DeploymentScheduler) Start ¶
func (s *DeploymentScheduler) Start(ctx context.Context) error
Start begins the deployment scheduler's event loop.
This method blocks until the context is cancelled or an error occurs. It processes events from the subscription channel established in the constructor.
Parameters:
- ctx: Context for cancellation and lifecycle management
Returns:
- nil when context is cancelled (graceful shutdown)
- Error only in exceptional circumstances
type DriftPreventionMonitor ¶
type DriftPreventionMonitor struct {
// contains filtered or unexported fields
}
DriftPreventionMonitor triggers periodic reconciliation to prevent configuration drift and keep HTTP Store caches warm across all replicas.
When no deployment has occurred within the configured interval, it publishes a DriftPreventionTriggeredEvent to trigger reconciliation. This helps detect and correct configuration drift caused by other Dataplane API clients or manual changes.
The component runs on ALL replicas (not just the leader) to ensure HTTP Store caches stay warm. Only the leader's DeploymentScheduler will actually deploy.
Event subscriptions:
- DeploymentCompletedEvent: Reset drift prevention timer
The component publishes DriftPreventionTriggeredEvent when drift prevention is needed.
func NewDriftPreventionMonitor ¶
func NewDriftPreventionMonitor(eventBus *busevents.EventBus, logger *slog.Logger, driftPreventionInterval time.Duration) *DriftPreventionMonitor
NewDriftPreventionMonitor creates a new DriftPreventionMonitor component.
The component is subscribed to the EventBus during construction to ensure proper startup synchronization without timing-based sleeps.
Parameters:
- eventBus: The EventBus for subscribing to events and publishing triggers
- logger: Structured logger for component logging
- driftPreventionInterval: Interval after which to trigger drift prevention deployment
Returns:
- A new DriftPreventionMonitor instance ready to be started
func (*DriftPreventionMonitor) HealthCheck ¶
func (m *DriftPreventionMonitor) HealthCheck() error
HealthCheck implements the lifecycle.HealthChecker interface. Returns an error if the component appears to be stalled (no timer tick for > stallTimeout). For a timer-based component like DriftPreventionMonitor, a healthy state means the timer is firing at the expected interval.
func (*DriftPreventionMonitor) Name ¶
func (m *DriftPreventionMonitor) Name() string
Name returns the unique identifier for this component. Implements the lifecycle.Component interface.
func (*DriftPreventionMonitor) Start ¶
func (m *DriftPreventionMonitor) Start(ctx context.Context) error
Start begins the drift prevention monitor's event loop.
This method blocks until the context is cancelled or an error occurs. The component is already subscribed to the EventBus (subscription happens in NewDriftPreventionMonitor()), so this method only processes events and manages the drift prevention timer:
- DeploymentCompletedEvent: Resets the drift prevention timer
- Drift timer expiration: Publishes DriftPreventionTriggeredEvent
The component runs until the context is cancelled, at which point it performs cleanup and returns.
Parameters:
- ctx: Context for cancellation and lifecycle management
Returns:
- nil when context is cancelled (graceful shutdown)
- Error only in exceptional circumstances