Documentation
¶
Overview ¶
Package mux multiplexes Kubernetes dynamic informers created on demand.
Each registered GroupVersionResource gets its own shared informer that lists existing objects and then watches for changes. All events are delivered on a single unified channel accessible via Mux.Events.
The underlying informers handle gap recovery automatically (HTTP 410 Gone, timeouts, etc.), so no events are missed. Consumers may see duplicates and should deduplicate if exactly-once semantics are required.
Index ¶
- Variables
- type Mux
- func (m *Mux) Add(gvr schema.GroupVersionResource) error
- func (m *Mux) Events() <-chan watch.Event
- func (m *Mux) GVRs() []schema.GroupVersionResource
- func (m *Mux) Has(gvr schema.GroupVersionResource) bool
- func (m *Mux) Len() int
- func (m *Mux) Remove(gvr schema.GroupVersionResource) bool
- func (m *Mux) Stop()
- type Option
Constants ¶
This section is empty.
Variables ¶
var ErrStopped = errors.New("mux is stopped")
ErrStopped is returned by Add when the Mux has already been stopped.
Functions ¶
This section is empty.
Types ¶
type Mux ¶
type Mux struct {
// contains filtered or unexported fields
}
Mux manages a dynamic set of Kubernetes informers and merges their events into a single channel. Watches can be added and removed at runtime. All methods are safe for concurrent use.
func New ¶
New creates a Mux that will create informers using the provided dynamic client. No watches are started until Add is called. The parent context controls the lifetime of all informers; canceling it is equivalent to calling Stop.
func (*Mux) Add ¶
func (m *Mux) Add(gvr schema.GroupVersionResource) error
Add registers a watch for the given GVR. It blocks until the informer's cache has synced (the initial list is complete). Calling Add for an already-watched GVR (including a concurrent Add for the same GVR) blocks until that watch has synced, then returns.
func (*Mux) Events ¶
Events returns the unified, read-only event stream. The channel is closed when Stop is called.
func (*Mux) GVRs ¶
func (m *Mux) GVRs() []schema.GroupVersionResource
GVRs returns all currently watched GroupVersionResources.
func (*Mux) Has ¶
func (m *Mux) Has(gvr schema.GroupVersionResource) bool
Has reports whether the given GVR is currently being watched.
type Option ¶
type Option func(*muxConfig)
Option configures a Mux during construction.
func WithBuffer ¶
WithBuffer sets the capacity of the internal event channel. Values below 1 are ignored and the default (1024) is used instead.
func WithFieldSelector ¶
WithFieldSelector applies a Kubernetes field selector to every informer created by this Mux.
func WithLabelSelector ¶
WithLabelSelector applies a Kubernetes label selector to every informer created by this Mux.