xds

package
v0.0.0-...-8571017 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2023 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Acknowledgment

type Acknowledgment struct {
	Node    string // The id of the node.
	Version string // The full version.
	Ack     bool   // Whether this is an ack or nack.
}

Acknowledgment is an event that represents the client accepting or rejecting a configuration.

type Manager

type Manager struct {
	// Name is the name of this manager, for logging/monitoring.
	Name string
	// VersionPrefix is a prefix to prepend to the version number, typically the server's pod name.
	VersionPrefix string
	// Type is the type of xDS resource being managed, like "type.googleapis.com/envoy.config.cluster.v3.Cluster".
	Type string
	// OnAck is a function that will be called when a config is accepted or rejected.
	OnAck func(Acknowledgment)
	// Logger is a zap logger to use to log manager events.  Per-connection events are logged
	// via the logger stored in the request context.
	Logger *zap.Logger
	// Draining is a channel that, when closed, will drain client connections.
	Draining chan struct{}
	// contains filtered or unexported fields
}

Manager consumes a stream of resource change, and notifies connected xDS clients of the change. It is not safe to mutate any public fields after the manager has received a client connection.

func NewManager

func NewManager(name, versionPrefix string, resource Resource, drainCh chan struct{}) *Manager

NewManager creates a new manager. resource is an instance of the type to manage.

func (*Manager) Add

func (m *Manager) Add(ctx context.Context, rs []Resource) error

Add adds or replaces (by name) managed resources, and notifies connected clients of the change.

func (*Manager) BuildDiscoveryResponse

func (m *Manager) BuildDiscoveryResponse(subscribed []string) (*discovery_v3.DiscoveryResponse, []string, error)

func (*Manager) ConfigAsYAML

func (m *Manager) ConfigAsYAML(verbose bool) ([]byte, error)

ConfigAsYAML dumps the currently-tracked resources as YAML.

func (*Manager) Delete

func (m *Manager) Delete(ctx context.Context, n string)

Delete deletes a single resource by name and notifies clients of the change.

func (*Manager) List

func (m *Manager) List() []Resource

List returns the managed resources.

func (*Manager) ListKeys

func (m *Manager) ListKeys() []string

ListKeys returns the sorted names of managed resources.

func (*Manager) Replace

func (m *Manager) Replace(ctx context.Context, rs []Resource) error

Replace repaces the entire set of managed resources with the provided argument, and notifies connected clients of the change.

func (*Manager) ServeHTTP

func (m *Manager) ServeHTTP(w http.ResponseWriter, req *http.Request)

ServeHTTP dumps the currently-tracked resources as YAML.

It will normally omit defaults, but with "?verbose" in the query params, it will print those too.

func (*Manager) Stream

func (m *Manager) Stream(ctx context.Context, reqCh chan *discovery_v3.DiscoveryRequest, resCh chan *discovery_v3.DiscoveryResponse) error

Stream manages a client connection. Requests from the client are read from reqCh, responses are written to resCh, and the function returns when no further progress can be made.

func (*Manager) StreamGRPC

func (m *Manager) StreamGRPC(stream Stream) error

StreamGRPC adapts a gRPC stream of DiscoveryRequest -> DiscoveryResponse to the API required by the Stream function.

type Resource

type Resource interface {
	proto.Message
	Validate() error
}

Resource is an xDS resource, like envoy_config_cluster_v3.Cluster, etc.

type Stream

type Stream interface {
	Context() context.Context
	Recv() (*discovery_v3.DiscoveryRequest, error)
	Send(*discovery_v3.DiscoveryResponse) error
}

Stream is the API shared among all envoy_api_v2.[type]DiscoveryService_Stream[type]Server streams.

Jump to

Keyboard shortcuts

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