watch_graph

package
v18.0.1 Latest Latest
Warning

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

Go to latest
Published: May 21, 2025 License: MIT Imports: 46 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ArcData

type ArcData []byte

type ArcToID

type ArcToID[VID, AT comparable] struct {
	To      VID
	ArcType AT
}

type ArcType

type ArcType byte

func (ArcType) String

func (at ArcType) String() string

type Error

type Error struct {
	Message string
	Code    ErrorCode
}

type ErrorCode

type ErrorCode byte
const (
	InvalidArgument ErrorCode
	Unavailable
	InternalError
)

type Namespaces

type Namespaces struct {
	Names                    []string
	LabelSelector            string
	FieldSelector            string
	ObjectSelectorExpression cel.Program // can be nil
}

func (*Namespaces) All

func (n *Namespaces) All() bool

All checks if all namespaces should be watched.

type ObjectGraph

type ObjectGraph[VID, AT comparable, VD, AD any] struct {
	// contains filtered or unexported fields
}

func NewObjectGraph

func NewObjectGraph[VID, AT comparable, VD, AD any](opts ObjectGraphOpts[VID, AT, VD, AD]) *ObjectGraph[VID, AT, VD, AD]

func (*ObjectGraph[VID, AT, VD, AD]) DeleteVertex

func (g *ObjectGraph[VID, AT, VD, AD]) DeleteVertex(vid VID)

DeleteVertex deletes the vertex with the specified VID. All outbound arcs are also deleted.

func (*ObjectGraph[VID, AT, VD, AD]) SetVertex

func (g *ObjectGraph[VID, AT, VD, AD]) SetVertex(vid VID, vd VD, arcs arcSet[VID, AT, AD])

SetVertex sets a vertex in the graph declaratively: - replaces the existing vertex or adds a new one with the specified VID. - replaces all outbound arcs of that vertex with the provided arcs. arcs may be nil.

type ObjectGraphOpts

type ObjectGraphOpts[VID, AT comparable, VD, AD any] struct {
	IsVertexDataEqual func(a, b VD) bool
	IsArcDataEqual    func(a, b AD) bool

	OnSetVertex    func(VID, VD)
	OnDeleteVertex func(VID)
	OnSetArc       func(from VID, to ArcToID[VID, AT], data AD)
	OnDeleteArc    func(from VID, to ArcToID[VID, AT])
}

type Opts

type Opts struct {
	Log         *slog.Logger
	Queries     []any // Elements are QueryInclude or QueryExclude
	Namespaces  Namespaces
	Roots       *rpc.Roots // can be nil
	RPCAPI      modshared.RPCAPI
	DiscoClient discovery.AggregatedDiscoveryInterface
	Client      dynamic.Interface
	OnWarning   func(Warning)
	Graph       *ObjectGraph[VertexID, ArcType, VertexData, ArcData]
}

type QueryExclude

type QueryExclude struct {
	ResourceSelectorExpression cel.Program // never nil
}

type QueryInclude

type QueryInclude struct {
	ResourceSelectorExpression cel.Program // never nil

	Object QueryIncludeObject
}

type QueryIncludeObject

type QueryIncludeObject struct {
	LabelSelector            string
	FieldSelector            string
	ObjectSelectorExpression cel.Program        // can be nil
	JSONPath                 *jsonpath.JSONPath // can be nil
}

QueryIncludeObject holds config for object filtering.

type VertexData

type VertexData struct {
	Object   []byte
	JSONPath []byte
}

type VertexID

type VertexID struct {
	GVR       schema.GroupVersionResource
	Namespace string
	Name      string
}

type Warning

type Warning struct {
	Type       string
	Message    string
	Attributes map[string]any
}

func NewObjectProcessingWarning

func NewObjectProcessingWarning(gvr schema.GroupVersionResource, namespace, name, message string) Warning

type WatchGraph

type WatchGraph struct {
	// contains filtered or unexported fields
}

func New

func New(opts Opts) *WatchGraph

func (*WatchGraph) Run

func (g *WatchGraph) Run(ctx context.Context) *Error

Jump to

Keyboard shortcuts

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