Documentation
¶
Index ¶
Constants ¶
const ( // ComponentName is the unique identifier for this component. ComponentName = "config-publisher" // EventBufferSize is the buffer size for the event subscription channel. // Large buffer to handle burst traffic during startup: ConfigPublisher makes // synchronous k8s API calls, so it processes events slowly compared to the // rate at which all-replica components publish them. EventBufferSize = busevents.PublishingSubscriberBuffer )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Component ¶
type Component struct {
*component.ReadySignal
// contains filtered or unexported fields
}
Component is the event adapter for the config publisher. It wraps the pure Publisher component and coordinates it with the event bus.
It publishes what the fleet was given: TemplateRenderedEvent is the trigger, and the render gate's later verdict lands on the same object as the ConfigValidated / ConfigPinned conditions (ADR-0022).
Rendered configs are cached by correlation ID because the publish worker is asynchronous and consumes the entry; a single-slot copy of the newest render outlives that eviction so a validation failure for the same reconcile can still publish those bytes as the invalid variant.
The component uses async workers for K8S API operations to prevent blocking the event loop. This ensures new events are processed promptly even when K8S API calls are slow.
func New ¶
func New( publisher *configpublisher.Publisher, eventBus *busevents.EventBus, logger *slog.Logger, opts ...Option, ) *Component
New creates a new config publisher component.
func (*Component) Drain ¶
Drain publishes the newest acknowledged checkpoint without waiting for the publish throttle, after handling every event delivered before the call. The publication runs under the term's context, so a lost Lease stops it.
func (*Component) Name ¶
Name returns the unique identifier for this component. Implements the lifecycle.Component interface.
func (*Component) Start ¶
Start begins the config publisher's event loop.
This method blocks until the context is cancelled or an error occurs. It subscribes to events when called (after leadership is acquired).
Parameters:
- ctx: Context for cancellation and lifecycle management
Returns:
- nil when context is cancelled (graceful shutdown)
- Error only in exceptional circumstances
type Option ¶
type Option func(*Component)
Option configures the Component.
func WithPublishInterval ¶
WithPublishInterval sets the throttle interval for CRD publishes. During endpoint churn each reconciliation produces a new config, but writing ~500 KB to etcd every 5 s is excessive. This interval limits CRD updates while deployments to HAProxy pods (event-driven) remain unaffected. A value of 0 disables throttling (every config is published immediately).
func WithTemplateConfig ¶
func WithTemplateConfig(templateConfig *v1alpha1.HAProxyTemplateConfig) Option
WithTemplateConfig seeds the HAProxyTemplateConfig the publications belong to. The iteration is built for exactly one, so the first render of a term never has to wait for the ConfigValidatedEvent that re-announces it.