Documentation
¶
Index ¶
- Constants
- type ConnectionRef
- type DeclarationBindings
- type DependencyNode
- type DependencyTree
- type Direction
- type GraphEdge
- type GraphNode
- type Indexer
- type RelatedRequest
- type RelatedResult
- type RelationshipGraph
- func (g *RelationshipGraph) AddDeclaredEdge(edge GraphEdge, declarerKey string, viaSelector bool)
- func (g *RelationshipGraph) AddEdge(edge GraphEdge)
- func (g *RelationshipGraph) CheckComplete(plugin string, route resource.AccessRoute) error
- func (g *RelationshipGraph) CheckLimit() error
- func (g *RelationshipGraph) ClearDeclarationsForConnection(plugin string, route resource.AccessRoute)
- func (g *RelationshipGraph) ClearDeclarationsForPlugin(pluginID string)
- func (g *RelationshipGraph) Close()
- func (g *RelationshipGraph) EdgesFrom(nodeKey string) []GraphEdge
- func (g *RelationshipGraph) EdgesTo(nodeKey string) []GraphEdge
- func (g *RelationshipGraph) GetBoundDeclarations(plugin string, route resource.AccessRoute, sourceType string) ([]resource.RelationshipDescriptor, DeclarationBindings, bool)
- func (g *RelationshipGraph) GetDependencyTree(ref GraphNode, maxDepth int) (*DependencyTree, error)
- func (g *RelationshipGraph) GetRelated(ref GraphNode, direction Direction, relType *RelationshipType) ([]GraphEdge, error)
- func (g *RelationshipGraph) GetRelationshipChain(ref GraphNode, relType RelationshipType, maxDepth int) ([][]GraphEdge, error)
- func (g *RelationshipGraph) GetSubgraph(ref GraphNode, upDepth, downDepth int) *Subgraph
- func (g *RelationshipGraph) ObserveDeclarationCatalog(plugin string, route resource.AccessRoute, catalogRevision string, ...)
- func (g *RelationshipGraph) QueryRelated(ref GraphNode, direction Direction, relType *RelationshipType, limit int, ...) (RelatedResult, error)
- func (g *RelationshipGraph) RecordDeclarationError(plugin string, route resource.AccessRoute, sourceType string, err error)
- func (g *RelationshipGraph) RemoveDerivedEdges(nodeKey string)
- func (g *RelationshipGraph) RemoveEdgesForConnection(pluginID, connectionID string)
- func (g *RelationshipGraph) RemoveEdgesForNode(nodeKey string)
- func (g *RelationshipGraph) SelectorScratchBytes() int
- func (g *RelationshipGraph) SetBoundDeclarations(plugin string, route resource.AccessRoute, sourceType string, ...) error
- func (g *RelationshipGraph) SetMemoryBudget(reserve func(int) bool, release func(int))
- func (g *RelationshipGraph) SetNoDeclarations(plugin string, route resource.AccessRoute, sourceType string)
- func (g *RelationshipGraph) VisitSelectorTargets(demands []SelectorDemand, visit func(resource.ReadTarget) error) error
- type RelationshipType
- type SelectorDemand
- type Subgraph
- type SubgraphNode
- type TargetBinding
Constants ¶
const ( // MethodFieldPath reads target IDs from a field path. MethodFieldPath = "fieldPath" // MethodLabelSelector reads a plain label map (a Service's spec.selector). // An empty or absent map selects nothing. MethodLabelSelector = "labelSelector" // MethodLabelSelectorObject reads a Kubernetes LabelSelector object // ({matchLabels, matchExpressions}, e.g. a NetworkPolicy's // spec.podSelector). An empty object selects every target in the // declared target scope; an absent one selects nothing. MethodLabelSelectorObject = "labelSelectorObject" )
Extractor methods understood by the indexer.
const ( RelOwns = resource.RelOwns RelRunsOn = resource.RelRunsOn RelUses = resource.RelUses RelExposes = resource.RelExposes RelManages = resource.RelManages RelMemberOf = resource.RelMemberOf )
const MaxResultBytes = 8 << 20
const MaxResultItems = 10000
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConnectionRef ¶ added in v0.4.2
ConnectionRef identifies one connection of one plugin.
type DeclarationBindings ¶ added in v0.12.0
type DeclarationBindings struct {
Source TargetBinding
Targets []TargetBinding
SourceEpoch uint64
}
DeclarationBindings belongs to one admitted source catalog epoch.
type DependencyNode ¶
type DependencyNode struct {
Edge GraphEdge `json:"edge"`
Children []DependencyNode `json:"children"`
}
type DependencyTree ¶
type DependencyTree struct {
Root GraphNode `json:"root"`
Children []DependencyNode `json:"children"`
}
type GraphEdge ¶
type GraphEdge struct {
Source GraphNode `json:"source"`
Target GraphNode `json:"target"`
Type RelationshipType `json:"type"`
Label string `json:"label"`
}
type GraphNode ¶
type GraphNode struct {
PluginID string `json:"pluginId"`
Reference resource.ResourceReference `json:"reference"`
Route resource.AccessRoute `json:"route"`
// contains filtered or unexported fields
}
GraphNode identifies a specific resource instance in the graph.
func (GraphNode) MarshalJSON ¶ added in v0.12.0
MarshalJSON supplies the host-issued key so clients never reconstruct identity.
type Indexer ¶ added in v0.4.0
type Indexer struct {
// contains filtered or unexported fields
}
func NewGraphIndexer ¶
func NewGraphIndexer(graph *RelationshipGraph, store registry.Store) *Indexer
func (*Indexer) CheckLabelSelectorsForEntry ¶ added in v0.4.0
func (gi *Indexer) CheckLabelSelectorsForEntry(entry registry.ResourceEntry)
CheckLabelSelectorsForEntry matches a newly added or updated entry against the cached selectors. Entries without labels are checked too: empty selectors and NotIn/DoesNotExist expressions can match them.
func (*Indexer) OnAdd ¶ added in v0.4.0
func (gi *Indexer) OnAdd(entry registry.ResourceEntry, raw json.RawMessage)
func (*Indexer) OnDelete ¶ added in v0.4.0
func (gi *Indexer) OnDelete(entry registry.ResourceEntry)
OnDelete withdraws the edges derived from this resource's data. Field-path edges other resources declared to it stay, like references to resources that do not exist yet, and resolve again if it is recreated.
func (*Indexer) OnUpdate ¶ added in v0.4.0
func (gi *Indexer) OnUpdate(old, updated registry.ResourceEntry, raw json.RawMessage)
OnUpdate re-derives the edges that come from this resource's data. Edges other resources declared about it (a Pod's "runs on" edge to an updated Node, a Pod's ownership edge from an updated ReplicaSet) are left alone.
type RelatedRequest ¶ added in v0.36.0
type RelatedRequest struct {
PluginID string `json:"pluginID"`
Reference resource.ResourceReference `json:"reference"`
Route resource.AccessRoute `json:"route"`
Direction string `json:"direction"`
RelationshipType *string `json:"relationshipType,omitempty"`
Limit int `json:"limit,omitempty"`
}
RelatedRequest bounds one finite semantic query. Zero requests the whole result; positive limits preserve explicit truncation without partial coverage.
type RelatedResult ¶ added in v0.36.0
type RelationshipGraph ¶
type RelationshipGraph struct {
// contains filtered or unexported fields
}
func NewRelationshipGraph ¶
func NewRelationshipGraph() *RelationshipGraph
func (*RelationshipGraph) AddDeclaredEdge ¶ added in v0.4.1
func (g *RelationshipGraph) AddDeclaredEdge(edge GraphEdge, declarerKey string, viaSelector bool)
AddDeclaredEdge adds an edge derived from the data of the node with key declarerKey. viaSelector marks edges found by matching the declarer's label selector. Such edges are withdrawn by RemoveDerivedEdges.
func (*RelationshipGraph) AddEdge ¶
func (g *RelationshipGraph) AddEdge(edge GraphEdge)
AddEdge adds an edge that is not tied to any declaring node. It is removed only by RemoveEdgesForNode or RemoveEdgesForConnection.
func (*RelationshipGraph) CheckComplete ¶ added in v0.12.0
func (g *RelationshipGraph) CheckComplete(plugin string, route resource.AccessRoute) error
CheckComplete rejects whole-result reads when this route has unresolved extraction.
func (*RelationshipGraph) CheckLimit ¶ added in v0.36.0
func (g *RelationshipGraph) CheckLimit() error
func (*RelationshipGraph) ClearDeclarationsForConnection ¶ added in v0.12.0
func (g *RelationshipGraph) ClearDeclarationsForConnection(plugin string, route resource.AccessRoute)
func (*RelationshipGraph) ClearDeclarationsForPlugin ¶
func (g *RelationshipGraph) ClearDeclarationsForPlugin(pluginID string)
func (*RelationshipGraph) Close ¶ added in v0.36.0
func (g *RelationshipGraph) Close()
Close releases projection charges and all retained metadata. Body storage is never owned by this graph. No publication may follow Close.
func (*RelationshipGraph) EdgesFrom ¶
func (g *RelationshipGraph) EdgesFrom(nodeKey string) []GraphEdge
func (*RelationshipGraph) EdgesTo ¶
func (g *RelationshipGraph) EdgesTo(nodeKey string) []GraphEdge
func (*RelationshipGraph) GetBoundDeclarations ¶ added in v0.12.0
func (g *RelationshipGraph) GetBoundDeclarations(plugin string, route resource.AccessRoute, sourceType string) ([]resource.RelationshipDescriptor, DeclarationBindings, bool)
func (*RelationshipGraph) GetDependencyTree ¶
func (g *RelationshipGraph) GetDependencyTree(ref GraphNode, maxDepth int) (*DependencyTree, error)
func (*RelationshipGraph) GetRelated ¶
func (g *RelationshipGraph) GetRelated(ref GraphNode, direction Direction, relType *RelationshipType) ([]GraphEdge, error)
GetRelated is the whole-result form used by bounded traversal planning.
func (*RelationshipGraph) GetRelationshipChain ¶
func (g *RelationshipGraph) GetRelationshipChain(ref GraphNode, relType RelationshipType, maxDepth int) ([][]GraphEdge, error)
GetRelationshipChain follows one relationship type breadth-first. Both output and visited/frontier storage are bounded before each new result is cloned.
func (*RelationshipGraph) GetSubgraph ¶ added in v0.4.2
func (g *RelationshipGraph) GetSubgraph(ref GraphNode, upDepth, downDepth int) *Subgraph
GetSubgraph returns the resources around ref: up to upDepth hops against edge direction and downDepth hops along it. Unlike GetDependencyTree it keeps every edge between the nodes it reaches, so a Node shared by many Pods is linked to each of them. Depths are capped at maxSubgraphDepth.
func (*RelationshipGraph) ObserveDeclarationCatalog ¶ added in v0.12.0
func (g *RelationshipGraph) ObserveDeclarationCatalog(plugin string, route resource.AccessRoute, catalogRevision string, sourceEpoch uint64, types []string)
ObserveDeclarationCatalog publishes complete admitted Type membership. Types outside this context cannot make queued observations poison current coverage.
func (*RelationshipGraph) QueryRelated ¶ added in v0.36.0
func (g *RelationshipGraph) QueryRelated(ref GraphNode, direction Direction, relType *RelationshipType, limit int, admit func(GraphEdge) error) (RelatedResult, error)
QueryRelated materializes only the requested edges. Admission also visits omitted matching citations, so truncation cannot hide a denied object. The callback receives immutable graph metadata and must not modify this graph.
func (*RelationshipGraph) RecordDeclarationError ¶ added in v0.12.0
func (g *RelationshipGraph) RecordDeclarationError(plugin string, route resource.AccessRoute, sourceType string, err error)
RecordDeclarationError records a failed host admission without inventing identity.
func (*RelationshipGraph) RemoveDerivedEdges ¶ added in v0.4.1
func (g *RelationshipGraph) RemoveDerivedEdges(nodeKey string)
RemoveDerivedEdges withdraws the edges derived from the given node's data: edges it declared (in either direction) and selector edges that matched its labels. Edges other nodes declared about it stay, so a change to a Node does not drop the Pods' "runs on" edges to it. Also drops the node's cached selector.
func (*RelationshipGraph) RemoveEdgesForConnection ¶
func (g *RelationshipGraph) RemoveEdgesForConnection(pluginID, connectionID string)
func (*RelationshipGraph) RemoveEdgesForNode ¶
func (g *RelationshipGraph) RemoveEdgesForNode(nodeKey string)
func (*RelationshipGraph) SelectorScratchBytes ¶ added in v0.36.0
func (g *RelationshipGraph) SelectorScratchBytes() int
SelectorScratchBytes bounds the temporary immutable selector-entry snapshot used while matching one changed candidate, including slice growth.
func (*RelationshipGraph) SetBoundDeclarations ¶ added in v0.12.0
func (g *RelationshipGraph) SetBoundDeclarations(plugin string, route resource.AccessRoute, sourceType string, decls []resource.RelationshipDescriptor, bindings DeclarationBindings) error
func (*RelationshipGraph) SetMemoryBudget ¶ added in v0.36.0
func (g *RelationshipGraph) SetMemoryBudget(reserve func(int) bool, release func(int))
SetMemoryBudget joins this demanded projection to its controller's existing accounting pool. The graph remains independently bounded without a callback. Configure before publishing declarations or observations.
func (*RelationshipGraph) SetNoDeclarations ¶ added in v0.12.0
func (g *RelationshipGraph) SetNoDeclarations(plugin string, route resource.AccessRoute, sourceType string)
SetNoDeclarations records a successful empty provider declaration response. No resource identity is needed because no extraction or citation can follow.
func (*RelationshipGraph) VisitSelectorTargets ¶ added in v0.36.0
func (g *RelationshipGraph) VisitSelectorTargets(demands []SelectorDemand, visit func(resource.ReadTarget) error) error
VisitSelectorTargets derives populations from extracted selector scopes, not guessed namespace conventions. The callback must not mutate this graph.
type RelationshipType ¶
type RelationshipType = resource.RelationshipType
RelationshipType re-exports from SDK for convenience.
type SelectorDemand ¶ added in v0.36.0
SelectorDemand is one actual node/direction in a bounded graph traversal. It does not grant access; the resource owner admits each resulting target.
type Subgraph ¶ added in v0.4.2
type Subgraph struct {
Root GraphNode `json:"root"`
Nodes []SubgraphNode `json:"nodes"`
Edges []GraphEdge `json:"edges"`
// Truncated reports that maxSubgraphNodes was reached and some nodes and
// their edges were left out.
Truncated bool `json:"truncated"`
}
Subgraph is the neighbourhood of one resource: the nodes reached by following edges up and down from it, and every edge followed between them.
type SubgraphNode ¶ added in v0.4.2
SubgraphNode is a node in a Subgraph with its distance from the root: negative upstream (resources pointing at the root, such as owners and selectors), positive downstream (resources the root points at), 0 for the root itself.
type TargetBinding ¶ added in v0.12.0
type TargetBinding struct {
Target resource.ReadTarget
IdentityDimensions []resource.Dimension
}
TargetBinding retains the host-admitted target and its exact identity schema.