xds

package
v0.0.0-...-ae413d2 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const ConfigInFlightThreshold = 100_000

Variables

This section is empty.

Functions

func NewLogger

func NewLogger(log logr.Logger) envoy_log.Logger

func SanitizeMetric

func SanitizeMetric(metric string) string

We need to sanitize metrics in order to not break statsd and prometheus format. StatsD only allow [a-zA-Z_\-0-9.] characters, everything else is removed Extra dots breaks many regexes that converts statsd metric to prometheus one with tags

Types

type Callbacks

type Callbacks interface {
	// OnStreamOpen is called once an xDS stream is opened with a stream ID and the type URL (or "" for ADS).
	// Returning an error will end processing and close the stream. OnStreamClosed will still be called.
	OnStreamOpen(context.Context, int64, string) error
	// OnStreamClosed is called immediately prior to closing an xDS stream with a stream ID.
	OnStreamClosed(int64)
	// OnStreamRequest is called once a request is received on a stream.
	// Returning an error will end processing and close the stream. OnStreamClosed will still be called.
	OnStreamRequest(int64, DiscoveryRequest) error
	// OnStreamResponse is called immediately prior to sending a response on a stream.
	OnStreamResponse(int64, DiscoveryRequest, DiscoveryResponse)
}

Callbacks defines Callbacks for xDS streaming requests. The difference over real go-control-plane Callbacks is that it takes an DiscoveryRequest / DiscoveryResponse interface. It helps us to implement Callbacks once for many different versions of Envoy API.

type DeltaCallbacks

type DeltaCallbacks interface {
	// OnDeltaStreamOpen is called once an xDS stream is opened with a stream ID and the type URL (or "" for ADS).
	// Returning an error will end processing and close the stream. OnDeltaStreamClosed will still be called.
	OnDeltaStreamOpen(context.Context, int64, string) error
	// OnDeltaStreamClosed is called immediately prior to closing an xDS stream with a stream ID.
	OnDeltaStreamClosed(int64)
	// OnStreamDeltaRequest is called once a request is received on a stream.
	// Returning an error will end processing and close the stream. OnDeltaStreamClosed will still be called.
	OnStreamDeltaRequest(int64, DeltaDiscoveryRequest) error
	// OnStreamDeltaResponse is called immediately prior to sending a response on a stream.
	OnStreamDeltaResponse(int64, DeltaDiscoveryRequest, DeltaDiscoveryResponse)
}

type DeltaDiscoveryRequest

type DeltaDiscoveryRequest interface {
	NodeId() string
	// Node returns either a v2 or v3 Node
	Node() interface{}
	Metadata() *structpb.Struct
	GetTypeUrl() string
	GetResponseNonce() string
	GetResourceNamesSubscribe() []string
	GetInitialResourceVersions() map[string]string
	HasErrors() bool
	ErrorMsg() string
}

type DeltaDiscoveryResponse

type DeltaDiscoveryResponse interface {
	GetTypeUrl() string
	GetResources() []*discoveryv3.Resource
	GetRemovedResources() []string
	GetNonce() string
}

DeltaDiscoveryResponse defines interface over real Envoy's DeltaDiscoveryResponse.

type DiscoveryRequest

type DiscoveryRequest interface {
	NodeId() string
	// Node returns either a v2 or v3 Node
	Node() interface{}
	Metadata() *structpb.Struct
	VersionInfo() string
	GetTypeUrl() string
	GetResponseNonce() string
	GetResourceNames() []string
	HasErrors() bool
	ErrorMsg() string
}

DiscoveryRequest defines interface over real Envoy's DiscoveryRequest.

type DiscoveryResponse

type DiscoveryResponse interface {
	GetTypeUrl() string
	VersionInfo() string
	GetResources() []*anypb.Any
	GetNonce() string
}

DiscoveryResponse defines interface over real Envoy's DiscoveryResponse.

type LoggingCallbacks

type LoggingCallbacks struct {
	Log logr.Logger
}

func (LoggingCallbacks) OnDeltaStreamClosed

func (cb LoggingCallbacks) OnDeltaStreamClosed(streamID int64)

OnDeltaStreamClosed is called immediately prior to closing an xDS stream with a stream ID.

func (LoggingCallbacks) OnDeltaStreamOpen

func (cb LoggingCallbacks) OnDeltaStreamOpen(ctx context.Context, streamID int64, typ string) error

OnDeltaStreamOpen is called once an xDS stream is open with a stream ID and the type URL (or "" for ADS). Returning an error will end processing and close the stream. OnDeltaStreamOpen will still be called.

func (LoggingCallbacks) OnFetchRequest

func (cb LoggingCallbacks) OnFetchRequest(ctx context.Context, req DiscoveryRequest) error

OnFetchRequest is called for each Fetch request. Returning an error will end processing of the request and respond with an error.

func (LoggingCallbacks) OnFetchResponse

func (cb LoggingCallbacks) OnFetchResponse(req DiscoveryRequest, resp DiscoveryResponse)

OnFetchRequest is called for each Fetch request. Returning an error will end processing of the request and respond with an error. OnFetchResponse is called immediately prior to sending a response.

func (LoggingCallbacks) OnStreamClosed

func (cb LoggingCallbacks) OnStreamClosed(streamID int64)

OnStreamClosed is called immediately prior to closing an xDS stream with a stream ID.

func (LoggingCallbacks) OnStreamDeltaRequest

func (cb LoggingCallbacks) OnStreamDeltaRequest(streamID int64, req DeltaDiscoveryRequest) error

OnStreamDeltaRequest is called once a request is received on a stream. Returning an error will end processing and close the stream. OnStreamDeltaRequest will still be called.

func (LoggingCallbacks) OnStreamDeltaResponse

func (cb LoggingCallbacks) OnStreamDeltaResponse(streamID int64, req DeltaDiscoveryRequest, resp DeltaDiscoveryResponse)

OnStreamDeltaResponse is called immediately prior to sending a response on a stream.

func (LoggingCallbacks) OnStreamOpen

func (cb LoggingCallbacks) OnStreamOpen(ctx context.Context, streamID int64, typ string) error

OnStreamOpen is called once an xDS stream is open with a stream ID and the type URL (or "" for ADS). Returning an error will end processing and close the stream. OnStreamClosed will still be called.

func (LoggingCallbacks) OnStreamRequest

func (cb LoggingCallbacks) OnStreamRequest(streamID int64, req DiscoveryRequest) error

OnStreamRequest is called once a request is received on a stream. Returning an error will end processing and close the stream. OnStreamClosed will still be called.

func (LoggingCallbacks) OnStreamResponse

func (cb LoggingCallbacks) OnStreamResponse(streamID int64, req DiscoveryRequest, resp DiscoveryResponse)

OnStreamResponse is called immediately prior to sending a response on a stream.

type MultiCallbacks

type MultiCallbacks interface {
	Callbacks
	RestCallbacks
}

MultiCallbacks implements callbacks for both rest and streaming xDS requests.

type NoopCallbacks

type NoopCallbacks struct{}

func (*NoopCallbacks) OnDeltaStreamClosed

func (n *NoopCallbacks) OnDeltaStreamClosed(int64)

func (*NoopCallbacks) OnDeltaStreamOpen

func (n *NoopCallbacks) OnDeltaStreamOpen(context.Context, int64, string) error

func (*NoopCallbacks) OnStreamClosed

func (n *NoopCallbacks) OnStreamClosed(int64)

func (*NoopCallbacks) OnStreamDeltaRequest

func (n *NoopCallbacks) OnStreamDeltaRequest(int64, DeltaDiscoveryRequest) error

func (*NoopCallbacks) OnStreamDeltaResponse

func (*NoopCallbacks) OnStreamOpen

func (n *NoopCallbacks) OnStreamOpen(context.Context, int64, string) error

func (*NoopCallbacks) OnStreamRequest

func (n *NoopCallbacks) OnStreamRequest(int64, DiscoveryRequest) error

func (*NoopCallbacks) OnStreamResponse

func (n *NoopCallbacks) OnStreamResponse(int64, DiscoveryRequest, DiscoveryResponse)

type RestCallbacks

type RestCallbacks interface {
	// OnFetchRequest is called when a new rest request comes in.
	// Returning an error will end processing. OnFetchResponse will not be called.
	OnFetchRequest(ctx context.Context, request DiscoveryRequest) error
	// OnFetchResponse is called immediately prior to sending a rest response.
	OnFetchResponse(request DiscoveryRequest, response DiscoveryResponse)
}

RestCallbacks defines rest.Callbacks for xDS fetch requests. The difference over real go-control-plane Callbacks is that it takes an DiscoveryRequest / DiscoveryResponse interface. It helps us to implement Callbacks once for many different versions of Envoy API.

type StatsCallbacks

type StatsCallbacks interface {
	// ConfigReadyForDelivery marks a configuration as a ready to be delivered.
	// This means that any config (EDS/CDS/DDS policies etc.) with specified version was set to a Snapshot
	// and it's scheduled to be delivered.
	ConfigReadyForDelivery(configVersion string)
	// DiscardConfig removes a configuration from being delivered.
	// This should be called when the client of xDS/DDS server disconnects.
	DiscardConfig(configVersion string)
	Callbacks
	DeltaCallbacks
}

func NewStatsCallbacks

func NewStatsCallbacks(metrics prometheus.Registerer, dsType string) (StatsCallbacks, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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