pubsub

package
v1.46.0-dev Latest Latest
Warning

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

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

Documentation

Overview

Package pubsub implements a utility type to maintain resource watchers and the updates.

This package is designed to work with the xds resources. It could be made a general system that works with all types.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Pubsub

type Pubsub struct {
	// contains filtered or unexported fields
}

Pubsub maintains resource watchers and resource updates.

There can be multiple watchers for the same resource. An update to a resource triggers updates to all the existing watchers. Watchers can be canceled at any time.

func New

func New(watchExpiryTimeout time.Duration, logger *grpclog.PrefixLogger) *Pubsub

New creates a new Pubsub.

func (*Pubsub) Close

func (pb *Pubsub) Close()

Close closes the pubsub.

func (*Pubsub) Dump

Dump dumps the resource for the given type.

func (*Pubsub) NewClusters

func (pb *Pubsub) NewClusters(updates map[string]xdsresource.ClusterUpdateErrTuple, metadata xdsresource.UpdateMetadata)

NewClusters is called when there's a new CDS update.

func (*Pubsub) NewConnectionError

func (pb *Pubsub) NewConnectionError(err error)

NewConnectionError is called by the underlying xdsAPIClient when it receives a connection error. The error will be forwarded to all the resource watchers.

func (*Pubsub) NewEndpoints

func (pb *Pubsub) NewEndpoints(updates map[string]xdsresource.EndpointsUpdateErrTuple, metadata xdsresource.UpdateMetadata)

NewEndpoints is called when there's anew EDS update.

func (*Pubsub) NewListeners

func (pb *Pubsub) NewListeners(updates map[string]xdsresource.ListenerUpdateErrTuple, metadata xdsresource.UpdateMetadata)

NewListeners is called when there's a new LDS update.

func (*Pubsub) NewRouteConfigs

func (pb *Pubsub) NewRouteConfigs(updates map[string]xdsresource.RouteConfigUpdateErrTuple, metadata xdsresource.UpdateMetadata)

NewRouteConfigs is called when there's a new RDS update.

func (*Pubsub) WatchCluster

func (pb *Pubsub) WatchCluster(clusterName string, cb func(xdsresource.ClusterUpdate, error)) (first bool, cancel func() bool)

WatchCluster register a watcher for the CDS resource.

It also returns whether this is the first watch for this resource.

func (*Pubsub) WatchEndpoints

func (pb *Pubsub) WatchEndpoints(clusterName string, cb func(xdsresource.EndpointsUpdate, error)) (first bool, cancel func() bool)

WatchEndpoints registers a watcher for the EDS resource.

It also returns whether this is the first watch for this resource.

func (*Pubsub) WatchListener

func (pb *Pubsub) WatchListener(serviceName string, cb func(xdsresource.ListenerUpdate, error)) (first bool, cancel func() bool)

WatchListener registers a watcher for the LDS resource.

It also returns whether this is the first watch for this resource.

func (*Pubsub) WatchRouteConfig

func (pb *Pubsub) WatchRouteConfig(routeName string, cb func(xdsresource.RouteConfigUpdate, error)) (first bool, cancel func() bool)

WatchRouteConfig register a watcher for the RDS resource.

It also returns whether this is the first watch for this resource.

type UpdateHandler

type UpdateHandler interface {
	// NewListeners handles updates to xDS listener resources.
	NewListeners(map[string]xdsresource.ListenerUpdateErrTuple, xdsresource.UpdateMetadata)
	// NewRouteConfigs handles updates to xDS RouteConfiguration resources.
	NewRouteConfigs(map[string]xdsresource.RouteConfigUpdateErrTuple, xdsresource.UpdateMetadata)
	// NewClusters handles updates to xDS Cluster resources.
	NewClusters(map[string]xdsresource.ClusterUpdateErrTuple, xdsresource.UpdateMetadata)
	// NewEndpoints handles updates to xDS ClusterLoadAssignment (or tersely
	// referred to as Endpoints) resources.
	NewEndpoints(map[string]xdsresource.EndpointsUpdateErrTuple, xdsresource.UpdateMetadata)
	// NewConnectionError handles connection errors from the xDS stream. The
	// error will be reported to all the resource watchers.
	NewConnectionError(err error)
}

UpdateHandler receives and processes (by taking appropriate actions) xDS resource updates from an APIClient for a specific version.

It's a subset of the APIs of a *Pubsub.

Jump to

Keyboard shortcuts

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