Documentation
¶
Overview ¶
Package resourceloader provides shared event loop infrastructure for loader components that watch a single resource type and parse/transform its data.
BaseLoader is a thin wrapper over pkg/controller/component.Base that keeps the ProcessEvent naming familiar to existing loader implementations (configloader, credentialsloader).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BaseLoader ¶
BaseLoader is a resource-loader flavoured wrapper around component.Base that exposes the same field accessors (EventBus, Logger, Name) as before and delegates event dispatch to the processor's ProcessEvent method.
Panics inside ProcessEvent are caught by the embedded base, logged with the event type and then swallowed so the event loop keeps running.
func NewBaseLoader ¶
func NewBaseLoader( eventBus *busevents.EventBus, logger *slog.Logger, name string, bufferSize int, processor EventProcessor, eventTypes ...string, ) *BaseLoader
NewBaseLoader creates a new base loader with the given configuration.
func (*BaseLoader) AssertUnstructured ¶
func (b *BaseLoader) AssertUnstructured(eventTypeName string, resource any) (*unstructured.Unstructured, bool)
AssertUnstructured type-asserts a resource carried by an event to *unstructured.Unstructured. On a type mismatch it logs an error tagged with the event type name and returns (nil, false); callers should early-return on a false result. Every loader on the bus receives resources via watcher events whose payloads are unstructured, so this is the single chokepoint for the "invalid resource type" failure mode.
func (*BaseLoader) HandleEvent ¶
func (b *BaseLoader) HandleEvent(event busevents.Event)
HandleEvent implements component.EventHandler by forwarding to the processor so loader implementations do not need to change their method name.
type EventProcessor ¶
type EventProcessor interface {
// ProcessEvent handles a single event from the EventBus.
ProcessEvent(event busevents.Event)
}
EventProcessor defines the interface for loader-specific event handling logic.
Each loader (configloader, credentialsloader) implements this interface to provide its specific parsing logic while reusing the common event loop infrastructure.