pubsub

package
v3.1.1 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2024 License: Apache-2.0 Imports: 10 Imported by: 2

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 dubbogoLogger.Logger) *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]resource.ClusterUpdateErrTuple, metadata resource.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]resource.EndpointsUpdateErrTuple, metadata resource.UpdateMetadata)

NewEndpoints is called when there's anew EDS update.

func (*Pubsub) NewListeners

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

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

func (*Pubsub) NewRouteConfigs

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

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

func (*Pubsub) WatchCluster

func (pb *Pubsub) WatchCluster(clusterName string, cb func(resource.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(resource.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(resource.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(resource.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]resource.ListenerUpdateErrTuple, resource.UpdateMetadata)
	// NewRouteConfigs handles updates to xDS RouteConfiguration resources.
	NewRouteConfigs(map[string]resource.RouteConfigUpdateErrTuple, resource.UpdateMetadata)
	// NewClusters handles updates to xDS Cluster resources.
	NewClusters(map[string]resource.ClusterUpdateErrTuple, resource.UpdateMetadata)
	// NewEndpoints handles updates to xDS ClusterLoadAssignment (or tersely
	// referred to as Endpoints) resources.
	NewEndpoints(map[string]resource.EndpointsUpdateErrTuple, resource.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