broadcast

package
v3.4.0 Latest Latest
Warning

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

Go to latest
Published: May 5, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Broadcaster

type Broadcaster[E any] interface {
	Subscribe(ch chan *E, filters ...func(event *E) bool) func()
	OnAdd(any, bool)
	OnUpdate(any, any)
	OnDelete(any)
}

Broadcaster is an interface for broadcasting informer watch events to multiple subscribers. T is the resource type (e.g., Application), E is the event type (e.g., ApplicationWatchEvent).

type EventFunc

type EventFunc[T any, E any] func(obj *T, eventType watch.EventType) *E

EventFunc creates a watch event from an object and event type. T is the resource type (e.g., Application), E is the event type (e.g., ApplicationWatchEvent).

type Handler

type Handler[T any, E any] struct {
	// contains filtered or unexported fields
}

Handler is a generic broadcaster handler that can be used for any resource type. T is the resource type (e.g., Application), E is the event type (e.g., ApplicationWatchEvent).

func NewHandler

func NewHandler[T any, E any](eventFunc EventFunc[T, E], logFields LogFieldsFunc[T]) *Handler[T, E]

NewHandler creates a new generic broadcaster handler. T is the resource type (e.g., Application), E is the event type (e.g., ApplicationWatchEvent).

func (*Handler[T, E]) OnAdd

func (b *Handler[T, E]) OnAdd(obj any, _ bool)

func (*Handler[T, E]) OnDelete

func (b *Handler[T, E]) OnDelete(obj any)

func (*Handler[T, E]) OnUpdate

func (b *Handler[T, E]) OnUpdate(_, newObj any)

func (*Handler[T, E]) Subscribe

func (b *Handler[T, E]) Subscribe(ch chan *E, filters ...func(event *E) bool) func()

Subscribe forwards informer watch events to the provided channel. The watch events are dropped if no receivers are reading events from the channel so the channel must have buffer if dropping events is not acceptable.

type LogFieldsFunc

type LogFieldsFunc[T any] func(obj *T) log.Fields

LogFieldsFunc returns log fields for an object (for logging dropped events)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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