command

package
v0.8.7 Latest Latest
Warning

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

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

Documentation

Overview

Package command owns the command model — the atomic unit of intent that flows through the CQRS engine. Controllers observe Kubernetes events, translate them into Commands, and hand them to the Engine. The Engine routes each Command to the correct Domain by GVK. Domains act on the Command and never interact with the controller layer directly.

The flow is strictly one-directional:

controller-runtime event → Command → Engine → Domain → reconciliation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Command

type Command struct {
	// Type is the lifecycle operation being requested.
	Type CommandType

	// GVK identifies which Domain should handle this Command.
	GVK schema.GroupVersionKind

	// Obj is the current object instance. Always populated.
	Obj client.Object

	// Old is the pre-update object state. Populated only for CmdUpdate.
	Old client.Object

	// New is the post-update object state. Populated only for CmdUpdate.
	// Equivalent to Obj on update — both are provided for clarity at call sites.
	New client.Object
}

Command is the atomic unit of intent in the BlanketOps CQRS engine. It is constructed by a controller from a controller-runtime reconcile request and routed by the Engine to the Domain whose GVK matches.

Old and New are populated only for CmdUpdate — they carry the previous and current object state so Domain predicates can diff specs without a separate API fetch.

func (Command) Clone

func (c Command) Clone() Command

Clone returns a shallow copy of the Command with Obj deep-copied. Old and New are not deep-copied — they are reference-copied. Use Clone when dispatching a Command to an async worker or retry queue where the caller may mutate Obj after dispatch.

func (Command) Name

func (c Command) Name() string

Name returns the object's name, or empty string if Obj is nil.

func (Command) Namespace

func (c Command) Namespace() string

Namespace returns the object's namespace, or empty string if Obj is nil.

func (Command) String

func (c Command) String() string

String returns a concise log-friendly representation of the command, suitable for structured log values and error messages.

type CommandType

type CommandType string

CommandType identifies the lifecycle operation being requested. Values align with the three controller-runtime event types and map directly to the CQRS create/update/delete intent model.

const (
	// CmdCreate is dispatched when a new object is observed for the first time.
	CmdCreate CommandType = "create"

	// CmdUpdate is dispatched when an existing object's spec has changed.
	// The CanUpdate predicate on the Domain determines whether the change
	// is significant enough to trigger reconciliation.
	CmdUpdate CommandType = "update"

	// CmdDelete is dispatched when an object is being removed. Domains use
	// this to perform cleanup — cache invalidation, child resource teardown,
	// or finalizer processing.
	CmdDelete CommandType = "delete"
)

Jump to

Keyboard shortcuts

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