coherentcache

package
v0.0.1-rc.0 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2026 License: Apache-2.0 Imports: 13 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package coherentcache is the consumer loop shared by the Kubernetes-backed semantic plugins. It subscribes to a plugin's resource collections and the Kubernetes coverage collection, keeps a cache from replay and live changes, and calls the plugin's projector only on a coherent snapshot: every resource collection and the coverage collection synced at the same Kubernetes generation. It then replaces the plugin's contribution at the plugin's next generation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(ctx context.Context, runtime discovery.Runtime, config Config) error

Run consumes the collections and replaces the contribution whenever both the objects and the coverage reach a new coherent generation. It returns on ctx cancellation, a subscription error or unexpected closure, a malformed change, or a failed projection or publication. Before returning for a subscription failure after a successful publication, it republishes the last coherent snapshot with degraded health.

Types

type Config

type Config struct {
	PluginID string
	SourceID string
	// Contribution is the name of the contribution Project fills.
	Contribution string
	Resources    []*kubernetesplugin.ResourceClient[*unstructured.Unstructured]
	// ReadyCollection, if set, is marked ready at each published generation
	// for plugins that consume this plugin's projection.
	ReadyCollection string
	// OnObjects, if set, receives each new coherent object set before it is
	// published, for example to refresh a telemetry resolver. It must not
	// modify the map or its objects.
	OnObjects func(map[string]Object)
	// Project returns the contribution input and the source health derived
	// from coverage. It must be a pure function of the snapshot.
	Project func(Snapshot) (graph.Input, string, error)
}

Config describes one semantic plugin instance.

type Object

type Object struct {
	Key        string
	Object     *unstructured.Unstructured
	EventID    string
	Revision   string
	ObservedAt time.Time
}

Object keeps collection delivery metadata beside the native object so projected assertions can cite the native event as evidence.

type Snapshot

type Snapshot struct {
	Objects []Object
	// Coverage is keyed by lowercase capability/GVR.
	Coverage map[string]kubernetesplugin.ResourceCoverage
}

Snapshot is one coherent immutable view of every consumed collection.

Jump to

Keyboard shortcuts

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