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 ¶
- type Pubsub
- func (pb *Pubsub) Close()
- func (pb *Pubsub) Dump(t xdsresource.ResourceType) map[string]xdsresource.UpdateWithMD
- func (pb *Pubsub) NewClusters(updates map[string]xdsresource.ClusterUpdateErrTuple, ...)
- func (pb *Pubsub) NewConnectionError(err error)
- func (pb *Pubsub) NewEndpoints(updates map[string]xdsresource.EndpointsUpdateErrTuple, ...)
- func (pb *Pubsub) NewListeners(updates map[string]xdsresource.ListenerUpdateErrTuple, ...)
- func (pb *Pubsub) NewRouteConfigs(updates map[string]xdsresource.RouteConfigUpdateErrTuple, ...)
- func (pb *Pubsub) WatchCluster(clusterName string, cb func(xdsresource.ClusterUpdate, error)) (first bool, cancel func() bool)
- func (pb *Pubsub) WatchEndpoints(clusterName string, cb func(xdsresource.EndpointsUpdate, error)) (first bool, cancel func() bool)
- func (pb *Pubsub) WatchListener(serviceName string, cb func(xdsresource.ListenerUpdate, error)) (first bool, cancel func() bool)
- func (pb *Pubsub) WatchRouteConfig(routeName string, cb func(xdsresource.RouteConfigUpdate, error)) (first bool, cancel func() bool)
- type UpdateHandler
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 ¶
New creates a new Pubsub.
The passed in nodeID will be attached to all errors sent to the watchers.
func (*Pubsub) Dump ¶
func (pb *Pubsub) Dump(t xdsresource.ResourceType) map[string]xdsresource.UpdateWithMD
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 ¶
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.