xds

package
v1.5.0-rc2 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

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.

func NewStatsCallbacks

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

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
	HasErrors() bool
	ErrorMsg() string
}

DiscoveryRequest defines interface over real Envoy's DiscoveryRequest.

type DiscoveryResponse

type DiscoveryResponse interface {
	GetTypeUrl() 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 struct {
	NoopCallbacks
	ResponsesSentMetric    *prometheus.CounterVec
	RequestsReceivedMetric *prometheus.CounterVec
	StreamsActive          int
	sync.RWMutex
}

func (*StatsCallbacks) OnStreamClosed

func (s *StatsCallbacks) OnStreamClosed(stream int64)

func (*StatsCallbacks) OnStreamOpen

func (s *StatsCallbacks) OnStreamOpen(ctx context.Context, stream int64, typ string) error

func (*StatsCallbacks) OnStreamRequest

func (s *StatsCallbacks) OnStreamRequest(stream int64, request DiscoveryRequest) error

func (*StatsCallbacks) OnStreamResponse

func (s *StatsCallbacks) OnStreamResponse(_ int64, _ DiscoveryRequest, response DiscoveryResponse)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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