event

package
v0.6.3 Latest Latest
Warning

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

Go to latest
Published: May 31, 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.

NoopRecorder

NoopRecorder implements the Recorder interface and discards all events. Used by ork simulate and tests that do not need Kubernetes event side-effects:

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

Swap *event.Event for *event.NoopRecorder anywhere a Recorder is accepted.

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 NoopRecorder added in v0.4.8

type NoopRecorder struct{}

NoopRecorder discards all events. Used in ork simulate.

func (*NoopRecorder) Eventf added in v0.4.8

func (n *NoopRecorder) Eventf(runtime.Object, string, string, string, ...interface{})

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. *NoopRecorder implements it for simulation — discards all events.

Jump to

Keyboard shortcuts

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