kubernetes

package
v1.18.0 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: 12 Imported by: 2

README

pkg/messaging/kubernetes

Intention

pkg/messaging/kubernetes is the current in-tree backend for pkg/messaging. It makes the queue contract work by wrapping controller-runtime manager/controller machinery around one watched Kubernetes object type and translating reconcile events into messaging.Envelope deliveries.

This is a real backend, but it is not evidence of a mature multi-backend queue abstraction. Today the abstraction has one implementation, and that implementation is essentially controller-runtime reconciliation dressed up as a queue.

What Lives Here

  • MessageQueue, which owns:
    • manager construction and leader election when run standalone
    • watch registration for one object type
    • in-process fan-out to registered consumers
  • Run(), which starts the manager and controller.
  • SetupWithManager(), which registers the controller with an existing controller-runtime manager.
  • Reconcile(), which loads the watched object and converts it into the minimal messaging.Envelope understood by consumers.

Relationships

Invariants

  • This backend watches exactly one Kubernetes object type per queue instance.
  • Leader election is always enabled because Kubernetes does not partition work like an external message broker would.
  • Delivery semantics come from controller-runtime reconciliation:
    • active objects are replayed by informer/controller startup behavior
    • consumer failure causes reconcile failure and therefore retry
  • The emitted envelope is intentionally sparse: resource name plus optional deletion timestamp. Consumers are expected to rehydrate real state from the system of record.

Caveats

  • This is not an independent queue model. It is a controller-runtime wrapper with queue-like semantics.
  • Only one backend exists today. Future Kafka/NATS-style backends are intended by the abstraction but have not yet pressure-tested it.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MessageQueue

type MessageQueue struct {
	client.Client
	// contains filtered or unexported fields
}

MessageQueue implements a message queue like interface using shared informers.

func New

func New(config *rest.Config, scheme *runtime.Scheme, object client.Object) *MessageQueue

func NewForManager added in v1.17.0

func NewForManager(object client.Object) *MessageQueue

NewForManager creates a queue that can be registered with an existing manager.

func (*MessageQueue) Reconcile

func (q *MessageQueue) Reconcile(ctx context.Context, request cr.Request) (cr.Result, error)

func (*MessageQueue) Run

func (q *MessageQueue) Run(ctx context.Context, consumers ...messaging.Consumer) error

func (*MessageQueue) SetupWithManager added in v1.17.0

func (q *MessageQueue) SetupWithManager(manager crmanager.Manager, consumers ...messaging.Consumer) error

SetupWithManager registers the queue's controller with an existing manager.

Jump to

Keyboard shortcuts

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