resourceloader

package
v0.1.0-alpha.12 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 27, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package resourceloader provides shared event loop infrastructure for loader components that watch a single resource type and parse/transform its data.

The pattern matches validator/base.go: each loader embeds a BaseLoader and implements EventProcessor to provide its resource-specific parsing logic.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseLoader

type BaseLoader struct {
	// contains filtered or unexported fields
}

BaseLoader provides common event loop infrastructure for all loader components.

It handles:

  • Event subscription and routing
  • Graceful shutdown via context or Stop()
  • Stop idempotency

Loaders embed this struct and provide an EventProcessor implementation for their specific parsing logic.

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.

Parameters:

  • eventBus: The EventBus to subscribe to and publish on
  • logger: Structured logger for diagnostics
  • name: Component name (used for logging and subscription)
  • bufferSize: Event subscription buffer size
  • processor: EventProcessor implementation for loader-specific logic
  • eventTypes: Event types to subscribe to (for type-filtered subscription)

func (*BaseLoader) EventBus

func (b *BaseLoader) EventBus() *busevents.EventBus

EventBus returns the event bus for use by the processor.

func (*BaseLoader) Logger

func (b *BaseLoader) Logger() *slog.Logger

Logger returns the logger for use by the processor.

func (*BaseLoader) Start

func (b *BaseLoader) Start(ctx context.Context) error

Start begins processing events from the EventBus.

This method blocks until Stop() is called or the context is canceled. The component is already subscribed to the EventBus (subscription happens in the constructor via NewBaseLoader). Returns nil on graceful shutdown.

func (*BaseLoader) Stop

func (b *BaseLoader) Stop()

Stop gracefully stops the loader. Safe to call multiple times.

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, certloader) implements this interface to provide its specific parsing logic while reusing the common event loop infrastructure.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL