Documentation
¶
Overview ¶
Package service provides the pipeline builder and runner for the flightctl-catalog-collector. It wires configured pipelines from a parsed config.Config and a set of catalogcollector.Factories, then supervises the running sources.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service holds the configured source and extension instances and supervises their execution.
func New ¶
func New( ctx context.Context, cfg *config.Config, factories catalogcollector.Factories, settings Settings, ) (*Service, error)
New builds the pipeline graph described by cfg using the supplied factories.
Factory lookup maps are built from each factory's Type method. Duplicate types within the same component kind, or empty types, are rejected.
Only sources, processors, and destinations referenced by at least one pipeline are constructed. Unreferenced definitions of those component kinds are ignored and do not require registered factories.
Every configured extension is constructed because extensions are global service capabilities and may be resolved by any component through Host.
Component lifecycle:
- A destination is constructed once per configured destination ID and may be shared by multiple pipeline branches. Each branch receives a small terminal Consumer that binds its pipeline ID to the shared destination.
- A processor is constructed for every occurrence in a pipeline because each processor instance is bound to that branch's next consumer.
- A source is constructed once per configured source ID.
- Every source receives one fan-out consumer containing all pipeline branches that reference that source. A single-pipeline source still receives a one-branch fan-out.
Pipeline branches are built backwards: destination first, followed by processors in reverse order. After every branch has been built, branches are grouped by source and each unique source is constructed once.
Errors identify pipelines and component IDs but never include raw component configuration, which may contain secrets.
func (*Service) Run ¶
Run starts configured extensions in deterministic order, then starts all source instances concurrently and blocks until they have stopped. Extensions are shut down in reverse start order after sources finish.
If an extension fails to start, already-started readiness extensions are marked not ready, then all already-started extensions are shut down in reverse order. No source is started.
If a source returns a non-nil error, the remaining sources are cancelled and Run returns an error identifying the failed source. Errors returned while a source delivers a snapshot through its fan-out already identify the failing pipeline.
Caller cancellation is treated as graceful shutdown. Source implementations must stop and return nil when their context is cancelled.
type Settings ¶
type Settings struct {
// Logger is the root logger for the service. It must not be nil. It is
// dedicated to the collector: service.New may change its level when
// cfg.Service.LogLevel is explicitly set.
// Component loggers are derived from it with component-scoped fields.
Logger *logrus.Logger
}
Settings carries service-level configuration for the catalog collector.