xds

package
v1.8.1 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2022 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 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) 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) 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) OnStreamClosed

func (n *NoopCallbacks) OnStreamClosed(int64)

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/KDS 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/KDS server disconnects.
	DiscardConfig(configVersion string)
	Callbacks
}

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