v3

package
v0.0.0-...-26094c9 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const RestStreamID = int64(-1)

RestStreamID is used in the non-streaming REST context

Variables

This section is empty.

Functions

func AdaptCallbacks

func AdaptCallbacks(callbacks xds.Callbacks) envoy_xds.Callbacks

AdaptCallbacks translate dubbo callbacks to real go-control-plane Callbacks

func AdaptDeltaCallbacks

func AdaptDeltaCallbacks(callbacks xds.DeltaCallbacks) envoy_xds.Callbacks

AdaptDeltaCallbacks translate dubbo callbacks to real go-control-plane Callbacks

func AdaptMultiCallbacks

func AdaptMultiCallbacks(callbacks xds.MultiCallbacks) envoy_xds.Callbacks

AdaptMultiCallbacks translate dubbo callbacks to real go-control-plane Callbacks

func AdaptRestCallbacks

func AdaptRestCallbacks(callbacks xds.RestCallbacks) envoy_xds.Callbacks

AdaptRestCallbacks translate dubbo callbacks to real go-control-plane Callbacks

func NewControlPlaneIdCallbacks

func NewControlPlaneIdCallbacks(id string) envoy_xds.Callbacks

func NewWatchdogCallbacks

func NewWatchdogCallbacks(newNodeWatchdog NewNodeWatchdogFunc) envoy_xds.Callbacks

Types

type CallbacksChain

type CallbacksChain []envoy_xds.Callbacks

func (CallbacksChain) OnDeltaStreamClosed

func (chain CallbacksChain) OnDeltaStreamClosed(streamID int64, node *envoy_core.Node)

func (CallbacksChain) OnDeltaStreamOpen

func (chain CallbacksChain) OnDeltaStreamOpen(ctx context.Context, streamID int64, typeURL string) error

func (CallbacksChain) OnFetchRequest

func (chain CallbacksChain) OnFetchRequest(ctx context.Context, req *envoy_sd.DiscoveryRequest) error

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

func (CallbacksChain) OnFetchResponse

func (chain CallbacksChain) OnFetchResponse(req *envoy_sd.DiscoveryRequest, resp *envoy_sd.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 (CallbacksChain) OnStreamClosed

func (chain CallbacksChain) OnStreamClosed(streamID int64, node *envoy_core.Node)

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

func (CallbacksChain) OnStreamDeltaRequest

func (chain CallbacksChain) OnStreamDeltaRequest(streamID int64, request *envoy_sd.DeltaDiscoveryRequest) error

func (CallbacksChain) OnStreamDeltaResponse

func (chain CallbacksChain) OnStreamDeltaResponse(streamID int64, request *envoy_sd.DeltaDiscoveryRequest, response *envoy_sd.DeltaDiscoveryResponse)

func (CallbacksChain) OnStreamOpen

func (chain CallbacksChain) 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 (CallbacksChain) OnStreamRequest

func (chain CallbacksChain) OnStreamRequest(streamID int64, req *envoy_sd.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 (CallbacksChain) OnStreamResponse

func (chain CallbacksChain) OnStreamResponse(ctx context.Context, streamID int64, req *envoy_sd.DiscoveryRequest, resp *envoy_sd.DiscoveryResponse)

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

type IDHash

type IDHash struct{}

IDHash uses ID field as the node hash.

func (IDHash) ID

ID uses the node ID field

type NewNodeWatchdogFunc

type NewNodeWatchdogFunc func(ctx context.Context, node *envoy_core.Node, streamId int64) (util_watchdog.Watchdog, error)

type NodeHash

type NodeHash interface {
	// ID function defines a unique string identifier for the remote Envoy node.
	ID(node *envoy_config_core_v3.Node) string
}

NodeHash computes string identifiers for Envoy nodes.

type NoopCallbacks

type NoopCallbacks struct{}

func (*NoopCallbacks) OnDeltaStreamClosed

func (c *NoopCallbacks) OnDeltaStreamClosed(int64, *envoy_core.Node)

func (*NoopCallbacks) OnDeltaStreamOpen

func (c *NoopCallbacks) OnDeltaStreamOpen(ctx context.Context, i int64, s string) error

func (*NoopCallbacks) OnFetchRequest

func (*NoopCallbacks) OnFetchResponse

func (*NoopCallbacks) OnStreamClosed

func (c *NoopCallbacks) OnStreamClosed(int64, *envoy_core.Node)

func (*NoopCallbacks) OnStreamDeltaRequest

func (c *NoopCallbacks) OnStreamDeltaRequest(i int64, request *envoy_sd.DeltaDiscoveryRequest) error

func (*NoopCallbacks) OnStreamDeltaResponse

func (c *NoopCallbacks) OnStreamDeltaResponse(i int64, request *envoy_sd.DeltaDiscoveryRequest, response *envoy_sd.DeltaDiscoveryResponse)

func (*NoopCallbacks) OnStreamOpen

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

func (*NoopCallbacks) OnStreamRequest

func (c *NoopCallbacks) OnStreamRequest(int64, *envoy_sd.DiscoveryRequest) error

func (*NoopCallbacks) OnStreamResponse

type ResponseWatch

type ResponseWatch struct {
	// Request is the original request for the watch.
	Request *envoy_cache.Request

	// Response is the channel to push responses to.
	Response chan envoy_cache.Response
}

ResponseWatch is a watch record keeping both the request and an open channel for the response.

type Snapshot

type Snapshot interface {
	// GetSupportedTypes returns a list of xDS types supported by this snapshot.
	GetSupportedTypes() []string

	// Consistent check verifies that the dependent resources are exactly listed in the
	// snapshot:
	// - all EDS resources are listed by name in CDS resources
	// - all RDS resources are listed by name in LDS resources
	//
	// Note that clusters and listeners are requested without name references, so
	// Envoy will accept the snapshot list of clusters as-is even if it does not match
	// all references found in xDS.
	Consistent() error

	// GetResources selects snapshot resources by type.
	GetResources(typ string) map[string]types.Resource

	// GetVersion returns the version for a resource type.
	GetVersion(typ string) string

	// WithVersion creates a new snapshot with a different version for a given resource type.
	WithVersion(typ string, version string) Snapshot
}

type SnapshotAutoVersioner

type SnapshotAutoVersioner struct {
	UUID func() string
}

SnapshotAutoVersioner assigns versions to xDS resources in a new Snapshot by reusing if possible a version from the old snapshot and generating a new version (UUID) otherwise.

func (SnapshotAutoVersioner) Version

func (v SnapshotAutoVersioner) Version(new, old Snapshot) Snapshot

type SnapshotCache

type SnapshotCache interface {
	envoy_cache.Cache

	// SetSnapshot sets a response snapshot for a node. For ADS, the snapshots
	// should have distinct versions and be internally consistent (e.g. all
	// referenced resources must be included in the snapshot).
	//
	// This method will cause the server to respond to all open watches, for which
	// the version differs from the snapshot version.
	SetSnapshot(node string, snapshot Snapshot) error

	// GetSnapshot gets the snapshot for a node.
	GetSnapshot(node string) (Snapshot, error)

	// HasSnapshot checks whether there is a snapshot present for a node.
	HasSnapshot(node string) bool

	// ClearSnapshot removes all status and snapshot information associated with a node. Return the removed snapshot or nil
	ClearSnapshot(node string) Snapshot

	// GetStatusInfo retrieves status information for a node ID.
	GetStatusInfo(string) StatusInfo

	// GetStatusKeys retrieves node IDs for all statuses.
	GetStatusKeys() []string
}

SnapshotCache is a snapshot-based envoy_cache that maintains a single versioned snapshot of responses per node. SnapshotCache consistently replies with the latest snapshot. For the protocol to work correctly in ADS mode, EDS/RDS requests are responded only when all resources in the snapshot xDS response are named as part of the request. It is expected that the CDS response names all EDS clusters, and the LDS response names all RDS routes in a snapshot, to ensure that Envoy makes the request for all EDS clusters or RDS routes eventually.

SnapshotCache can operate as a REST or regular xDS backend. The snapshot can be partial, e.g. only include RDS or EDS resources.

func NewSnapshotCache

func NewSnapshotCache(ads bool, hash NodeHash, logger log.Logger) SnapshotCache

NewSnapshotCache initializes a simple envoy_cache.

ADS flag forces a delay in responding to streaming requests until all resources are explicitly named in the request. This avoids the problem of a partial request over a single stream for a subset of resources which would require generating a fresh version for acknowledgement. ADS flag requires snapshot consistency. For non-ADS case (and fetch), multiple partial requests are sent across multiple streams and re-using the snapshot version is OK.

Logger is optional.

type SnapshotGenerator

type SnapshotGenerator interface {
	GenerateSnapshot(context.Context, *envoy_config_core_v3.Node) (Snapshot, error)
}

Generates a snapshot of xDS resources for a given node.

type SnapshotVersioner

type SnapshotVersioner interface {
	Version(new, old Snapshot) Snapshot
}

SnapshotVersioner assigns versions to xDS resources in a new Snapshot.

type StatusInfo

type StatusInfo interface {
	// GetNode returns the node metadata.
	GetNode() *envoy_config_core_v3.Node

	// GetNumWatches returns the number of open watches.
	GetNumWatches() int

	// GetLastWatchRequestTime returns the timestamp of the last discovery watch request.
	GetLastWatchRequestTime() time.Time
}

StatusInfo tracks the server state for the remote Envoy node. Not all fields are used by all envoy_cache implementations.

Jump to

Keyboard shortcuts

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