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 (200) 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 = 200 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Component ¶
type Component struct {
// 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.
This component caches information from multiple events (ConfigValidatedEvent, TemplateRenderedEvent) and publishes runtime config resources only after successful HAProxy validation (ValidationCompletedEvent).
Rendered configs are cached by correlation ID to ensure we match the correct TemplateRenderedEvent with its corresponding ValidationCompletedEvent, even when events from multiple reconciliation cycles are interleaved.
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, ) *Component
New creates a new config publisher component.
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
func (*Component) SubscriptionReady ¶
func (c *Component) SubscriptionReady() <-chan struct{}
SubscriptionReady returns a channel that is closed when the component has completed its event subscription. This implements lifecycle.SubscriptionReadySignaler.