collector

package
v0.0.3-alpha2 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultBufferSize     = 4096
	DefaultRestartBackoff = 5 * time.Second
)

Defaults used when New is given a non-positive value.

Variables

This section is empty.

Functions

func NewPollSource

func NewPollSource(name string, interval time.Duration, poll PollFunc) runtimeevent.Source

NewPollSource builds a Source that calls poll every interval and emits whatever it returns. A non-positive interval defaults to one second; a nil poll function is a wiring bug and panics here rather than at the first tick.

Types

type Collector

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

Collector wires sources to sinks. Build it with New, register components before calling Run, then call Run exactly once.

func New

func New(log logr.Logger, bufferSize int, backoff time.Duration, m *metrics.Metrics) *Collector

New builds a Collector. Sources, stages, and sinks are registered separately so that daemon wiring can be conditional.

func (*Collector) AddSink

func (c *Collector) AddSink(s runtimeevent.Sink)

AddSink registers a consumer. Every sink sees every event that survives all stages; a panicking sink does not affect the others.

func (*Collector) AddSource

func (c *Collector) AddSource(src runtimeevent.Source)

AddSource registers an event producer. Nil sources are ignored.

func (*Collector) AddStage

func (c *Collector) AddStage(s Stage)

AddStage appends a stage. Stages run in registration order, and the first one to return false drops the event.

func (*Collector) Dropped

func (c *Collector) Dropped() int64

Dropped returns the total number of events dropped for any reason (buffer full, or rejected/panicked stage) since New.

func (*Collector) Run

func (c *Collector) Run(ctx context.Context) error

Run starts one goroutine per source plus a single dispatch goroutine, and blocks until ctx is cancelled. It returns nil on cancellation; a second call returns an error.

type PollFunc

type PollFunc func(ctx context.Context) ([]runtimeevent.Event, error)

PollFunc returns the events observed since the previous call. It is called once per interval and must not block indefinitely; returning an error stops the source, which the collector then restarts with backoff.

type Stage

type Stage interface {
	Name() string
	Process(ev *runtimeevent.Event) bool
}

Stage mutates/filters an event before sinks see it (attribution). Return false to drop.

Jump to

Keyboard shortcuts

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