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 ¶
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.