event

package
v0.7.8 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

README

pkg/event

event wraps the Kubernetes event recorder so that reconcilers and control-plane components can emit corev1.Event objects without depending directly on client-go/tools/record.

e := event.NewEvent(kube)
e.Start(ctx)

e.Eventf(obj, corev1.EventTypeNormal, "Reconciled", "created %s", name)

Event recording

Eventf records events asynchronously — it spawns a goroutine per call and tracks in-flight work with a sync.WaitGroup. This prevents event recording from blocking the reconcile loop on API server latency.

Events are discarded silently once Shutdown() is called, so no goroutine leaks after the broadcaster is shut down.

Shutdown

Shutdown() sets a stopped flag, waits for all in-flight events to flush (with the given context deadline as a timeout), then calls broadcaster.Shutdown() to release the underlying connection. A context timeout produces a warning log but is otherwise clean.

Recorder interface

Recorder is declared in this package and is the only surface that reconcilers and constructors depend on:

type Recorder interface {
    Eventf(obj runtime.Object, eventType, reason, messageFmt string, args ...interface{})
}

*Event implements Recorder for real clusters. Passing nil is safe anywhere that nil-coalesces internally (e.g. NewGenericReconciler). Constructor functions (NewReconcilerFunc) receive event.Recorder and should guard with if ev != nil before calling Eventf.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

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

func NewEvent

func NewEvent(kube *kubeclient.Kubeclient) *Event

func (*Event) Broadcaster

func (e *Event) Broadcaster() record.EventBroadcaster

func (*Event) Eventf

func (e *Event) Eventf(object runtime.Object, eventtype, reason, messageFmt string, args ...interface{})

Eventf - track in-flight events

func (*Event) Name

func (e *Event) Name() string

func (*Event) Recorder

func (e *Event) Recorder() record.EventRecorder

func (*Event) Shutdown

func (e *Event) Shutdown(ctx context.Context)

func (*Event) Start

func (e *Event) Start(ctx context.Context) error

func (*Event) Started

func (e *Event) Started() bool

Healthy mark on startup

type Recorder added in v0.4.8

type Recorder interface {
	Eventf(obj runtime.Object, eventType, reason, messageFmt string, args ...interface{})
}

Recorder is the interface for emitting Kubernetes events. *Event implements this for real clusters; Discard() returns a silent no-op.

func Discard added in v0.7.1

func Discard() Recorder

Discard returns a Recorder that silently drops all events. Passed to constructors by ork simulate so ev is always non-nil.

Jump to

Keyboard shortcuts

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