Documentation
¶
Index ¶
- func HandleSubscription[K comparable, V any](l logging.Logger, meta Metadata, subscription <-chan watchable.Snapshot[K, V], ...)
- func PublishMetric(meta Metadata, count int)
- func PublishRunnerEventMetric(runnerName string, isDelete bool)
- func RecordQueueWait(ctx context.Context, tracer trace.Tracer, runnerName string, ...) (context.Context, []trace.SpanStartOption)
- type ExtensionStatuses
- type GatewayAPIStatuses
- type InfraIR
- type InfraIRWithContext
- type MessageName
- type Metadata
- type NamespacedNameAndGVK
- type PolicyStatuses
- type ProviderResources
- type RunnerErrorNotifier
- type RunnerErrors
- type Update
- type WatchableError
- type XdsIR
- type XdsIRWithContext
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HandleSubscription ¶
func HandleSubscription[K comparable, V any](l logging.Logger, meta Metadata, subscription <-chan watchable.Snapshot[K, V], handle func(updateFunc Update[K, V], errChans chan error), )
HandleSubscription takes a channel returned by watchable.Map.Subscribe() (or .SubscribeSubset()), and calls the given function for each initial value in the map, and for any updates.
This is better than simply iterating over snapshot.Updates because it handles the case where the watchable.Map already contains entries before .Subscribe is called.
func PublishMetric ¶ added in v1.5.0
func PublishRunnerEventMetric ¶ added in v1.8.0
func RecordQueueWait ¶ added in v1.8.4
func RecordQueueWait(ctx context.Context, tracer trace.Tracer, runnerName string, storedAt time.Time) (context.Context, []trace.SpanStartOption)
RecordQueueWait records, as a short-lived "WatchableQueue.Wait" span, how long a value sat buffered in a watchable map's internal queue between being Store()'d (storedAt) and being dequeued by this subscriber (now). The span is backdated to storedAt so it shows up as a real gap in the trace waterfall between the producer's span and the subscriber's own processing span, rather than being folded into either one's duration.
The wait span and the caller's processing span are siblings, because a completed span must never become the parent of later work. To preserve the causal edge in backends that render links, this returns SpanStartOptions that link the caller's eventual processing span back to the recorded wait span.
storedAt is the zero Time for values that were already present in the map when the subscriber first subscribed (e.g. at process startup) rather than having transited the queue; those carry no meaningful wait, so no span is recorded and ctx is returned unchanged with no link options.
runnerName identifies the subscriber recording the wait (e.g. r.Name()), so waits from different runners draining the same watchable map can be told apart in a trace backend.
Types ¶
type ExtensionStatuses ¶ added in v1.1.1
type ExtensionStatuses struct {
BackendStatuses watchable.Map[types.NamespacedName, *egv1a1.BackendStatus]
}
ExtensionStatuses contains statuses related to gw-api extension resources
func (*ExtensionStatuses) Close ¶ added in v1.5.3
func (e *ExtensionStatuses) Close()
type GatewayAPIStatuses ¶ added in v0.6.0
type GatewayAPIStatuses struct {
GatewayClassStatuses watchable.Map[types.NamespacedName, *gwapiv1.GatewayClassStatus]
GatewayStatuses watchable.Map[types.NamespacedName, *gwapiv1.GatewayStatus]
HTTPRouteStatuses watchable.Map[types.NamespacedName, *gwapiv1.HTTPRouteStatus]
GRPCRouteStatuses watchable.Map[types.NamespacedName, *gwapiv1.GRPCRouteStatus]
TLSRouteStatuses watchable.Map[types.NamespacedName, *gwapiv1.TLSRouteStatus]
TCPRouteStatuses watchable.Map[types.NamespacedName, *gwapiv1.TCPRouteStatus]
UDPRouteStatuses watchable.Map[types.NamespacedName, *gwapiv1.UDPRouteStatus]
ListenerSetStatuses watchable.Map[types.NamespacedName, *gwapiv1.ListenerSetStatus]
}
GatewayAPIStatuses contains gateway API resources statuses
func (*GatewayAPIStatuses) Close ¶ added in v0.6.0
func (s *GatewayAPIStatuses) Close()
type InfraIRWithContext ¶ added in v1.8.4
type InfraIRWithContext struct {
Infra *ir.Infra
Context context.Context
// StoredAt is when this value was Store()'d into the watchable map. Subscribers use it to
// record how long the value sat buffered in the map's internal queue before being
// dequeued; see RecordQueueWait.
StoredAt time.Time
}
InfraIRWithContext wraps ir.Infra with trace context for propagating spans across the InfraIR watchable-map boundary, the same way XdsIRWithContext does for XdsIR.
func (*InfraIRWithContext) DeepCopy ¶ added in v1.8.4
func (x *InfraIRWithContext) DeepCopy() *InfraIRWithContext
DeepCopy creates a new InfraIRWithContext. The Context field is preserved (not deep copied) since contexts are meant to be passed around.
func (*InfraIRWithContext) Equal ¶ added in v1.8.4
func (x *InfraIRWithContext) Equal(other *InfraIRWithContext) bool
func (*InfraIRWithContext) ParentContext ¶ added in v1.8.4
func (x *InfraIRWithContext) ParentContext(fallback context.Context) context.Context
ParentContext adds the trace context stashed on x to fallback without replacing fallback's cancellation and values.
func (*InfraIRWithContext) StoredAtTime ¶ added in v1.8.4
func (x *InfraIRWithContext) StoredAtTime() time.Time
StoredAtTime returns the time x was stored in the watchable map, or the zero Time if x is nil.
type MessageName ¶ added in v1.5.0
type MessageName string
const ( // XDSIRMessageName is a message containing xds-ir translated from provider-resources XDSIRMessageName MessageName = "xds-ir" // InfraIRMessageName is a message containing infra-ir translated from provider-resources InfraIRMessageName MessageName = "infra-ir" // ProviderResourcesMessageName is a message containing gw-api and envoy gateway resources from the provider ProviderResourcesMessageName MessageName = "provider-resources" // BackendStatusMessageName is a message containing updates to Backend status BackendStatusMessageName MessageName = "backend-status" // ExtensionServerPoliciesStatusMessageName is a message containing updates to ExtensionServerPolicy status ExtensionServerPoliciesStatusMessageName MessageName = "extensionserverpolicies-status" // EnvoyExtensionPolicyStatusMessageName is a message containing updates to EnvoyExtensionPolicy status EnvoyExtensionPolicyStatusMessageName MessageName = "envoyextensionpolicy-status" // EnvoyPatchPolicyStatusMessageName is a message containing updates to EnvoyPatchPolicy status EnvoyPatchPolicyStatusMessageName MessageName = "envoypatchpolicy-status" // SecurityPolicyStatusMessageName is a message containing updates to SecurityPolicy status SecurityPolicyStatusMessageName MessageName = "securitypolicy-status" // BackendTrafficPolicyStatusMessageName is a message containing updates to BackendTrafficPolicy status BackendTrafficPolicyStatusMessageName MessageName = "backendtrafficpolicy-status" // ClientTrafficPolicyStatusMessageName is a message containing updates to ClientTrafficPolicy status ClientTrafficPolicyStatusMessageName MessageName = "clienttrafficpolicy-status" // BackendTLSPolicyStatusMessageName is a message containing updates to BackendTLSPolicy status BackendTLSPolicyStatusMessageName MessageName = "backendtlspolicy-status" // UDPRouteStatusMessageName is a message containing updates to UDPRoute status UDPRouteStatusMessageName MessageName = "udproute-status" // TCPRouteStatusMessageName is a message containing updates to TCPRoute status TCPRouteStatusMessageName MessageName = "tcproute-status" // TLSRouteStatusMessageName is a message containing updates to TLSRoute status TLSRouteStatusMessageName MessageName = "tlsroute-status" // GRPCRouteStatusMessageName is a message containing updates to GRPCRoute status GRPCRouteStatusMessageName MessageName = "grpcroute-status" // HTTPRouteStatusMessageName is a message containing updates to HTTPRoute status HTTPRouteStatusMessageName MessageName = "httproute-status" // GatewayStatusMessageName is a message containing updates to Gateway status GatewayStatusMessageName MessageName = "gateway-status" // ListenerSetStatusMessageName is a message containing updates to ListenerSet status ListenerSetStatusMessageName MessageName = "listenerset-status" // GatewayClassStatusMessageName is a message containing updates to GatewayClass status GatewayClassStatusMessageName MessageName = "gatewayclass-status" // EnvoyProxyStatusMessageName is a message containing updates to EnvoyProxy status EnvoyProxyStatusMessageName MessageName = "envoyproxy-status" )
const RunnerErrorsMessageName MessageName = "runner-errors"
RunnerErrorsMessageName is the name of the RunnerErrors message
type Metadata ¶ added in v0.6.0
type Metadata struct {
Runner string
Message MessageName
}
func (Metadata) LabelValues ¶ added in v0.6.0
func (m Metadata) LabelValues() []metrics.LabelValue
type NamespacedNameAndGVK ¶ added in v1.1.0
type NamespacedNameAndGVK struct {
types.NamespacedName
schema.GroupVersionKind
}
type PolicyStatuses ¶ added in v0.6.0
type PolicyStatuses struct {
ClientTrafficPolicyStatuses watchable.Map[types.NamespacedName, *gwapiv1.PolicyStatus]
BackendTrafficPolicyStatuses watchable.Map[types.NamespacedName, *gwapiv1.PolicyStatus]
EnvoyPatchPolicyStatuses watchable.Map[types.NamespacedName, *gwapiv1.PolicyStatus]
SecurityPolicyStatuses watchable.Map[types.NamespacedName, *gwapiv1.PolicyStatus]
BackendTLSPolicyStatuses watchable.Map[types.NamespacedName, *gwapiv1.PolicyStatus]
EnvoyExtensionPolicyStatuses watchable.Map[types.NamespacedName, *gwapiv1.PolicyStatus]
ExtensionPolicyStatuses watchable.Map[NamespacedNameAndGVK, *gwapiv1.PolicyStatus]
EnvoyProxyStatuses watchable.Map[types.NamespacedName, *egv1a1.EnvoyProxyStatus]
}
PolicyStatuses contains policy related resources statuses
func (*PolicyStatuses) Close ¶ added in v0.6.0
func (p *PolicyStatuses) Close()
type ProviderResources ¶
type ProviderResources struct {
// GatewayAPIResources is a map from a GatewayClass name to
// a group of gateway API and other related resources with trace context.
GatewayAPIResources watchable.Map[string, *resource.ControllerResourcesContext]
// GatewayAPIStatuses is a group of gateway api
// resource statuses maps.
GatewayAPIStatuses
// PolicyStatuses is a group of policy statuses maps.
PolicyStatuses
// ExtensionStatuses is a group of gw-api extension resource statuses map.
ExtensionStatuses
}
ProviderResources message
func (*ProviderResources) Close ¶ added in v0.3.0
func (p *ProviderResources) Close()
func (*ProviderResources) GetResources ¶ added in v0.3.0
func (p *ProviderResources) GetResources() []*resource.Resources
func (*ProviderResources) GetResourcesByGatewayClass ¶ added in v1.0.0
func (p *ProviderResources) GetResourcesByGatewayClass(name string) *resource.Resources
func (*ProviderResources) GetResourcesKey ¶ added in v0.3.0
func (p *ProviderResources) GetResourcesKey() string
type RunnerErrorNotifier ¶ added in v1.7.0
type RunnerErrorNotifier struct {
RunnerName string
RunnerErrors *RunnerErrors
}
RunnerErrorNotifier is a helper to notify errors with a specific runner name.
func (*RunnerErrorNotifier) Store ¶ added in v1.7.0
func (n *RunnerErrorNotifier) Store(err error)
Store the error.
type RunnerErrors ¶ added in v1.7.0
type RunnerErrors = watchable.Map[string, WatchableError]
RunnerErrors is a map of runner name to runnerError
type Update ¶
type Update[K comparable, V any] struct { Key K Value V Delete bool // Initial identifies an entry replayed from the map state when this subscriber // started. Its StoredAt describes resource age, not queue time for this subscriber. Initial bool }
type WatchableError ¶ added in v1.7.0
type WatchableError interface {
error
watchable.DeepCopier[WatchableError]
}
WatchableError is an error that can captured in a watchable.Map
func NewWatchableError ¶ added in v1.7.0
func NewWatchableError(err error) WatchableError
NewWatchableError creates a new WatchableError
type XdsIRWithContext ¶ added in v1.7.0
type XdsIRWithContext struct {
XdsIR *ir.Xds
Context context.Context
// StoredAt is when this value was Store()'d into the watchable map. Subscribers use it
// to record how long the value sat buffered in the map's internal queue before being
// dequeued; see RecordQueueWait.
StoredAt time.Time
}
func (*XdsIRWithContext) DeepCopy ¶ added in v1.7.0
func (x *XdsIRWithContext) DeepCopy() *XdsIRWithContext
DeepCopy creates a new ControllerResourcesContext. The Context field is preserved (not deep copied) since contexts are meant to be passed around.
func (*XdsIRWithContext) Equal ¶ added in v1.7.0
func (x *XdsIRWithContext) Equal(other *XdsIRWithContext) bool
func (*XdsIRWithContext) ParentContext ¶ added in v1.8.4
func (x *XdsIRWithContext) ParentContext(fallback context.Context) context.Context
ParentContext adds the trace context stashed on x to fallback without replacing fallback's cancellation and values.
func (*XdsIRWithContext) StoredAtTime ¶ added in v1.8.4
func (x *XdsIRWithContext) StoredAtTime() time.Time
StoredAtTime returns the time x was stored in the watchable map, or the zero Time if x is nil.