grpc: google.golang.org/grpc/xds/internal/client Index | Files | Directories

package client

import "google.golang.org/grpc/xds/internal/client"

Package client implementation a full fledged gRPC client for the xDS API used by the xds resolver and balancer implementations.

Index

Package Files

cds.go client.go client_loadreport.go eds.go eds_testutil.go lds.go rds.go types.go v2client.go

type AddLocalityOptions Uses

type AddLocalityOptions struct {
    Health []corepb.HealthStatus
    Weight []uint32
}

AddLocalityOptions contains options when adding locality to the builder.

type CDSUpdate Uses

type CDSUpdate struct {
    // ServiceName is the service name corresponding to the clusterName which
    // is being watched for through CDS.
    ServiceName string
    // EnableLRS indicates whether or not load should be reported through LRS.
    EnableLRS bool
}

CDSUpdate contains information from a received CDS response, which is of interest to the registered CDS watcher.

type Client Uses

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

Client is a full fledged gRPC client which queries a set of discovery APIs (collectively termed as xDS) on a remote management server, to discover various dynamic resources. A single client object will be shared by the xds resolver and balancer implementations.

func New Uses

func New(opts Options) (*Client, error)

New returns a new xdsClient configured with opts.

func (*Client) Close Uses

func (c *Client) Close()

Close closes the gRPC connection to the xDS server.

func (*Client) ReportLoad Uses

func (c *Client) ReportLoad(server string, clusterName string, loadStore lrs.Store) func()

ReportLoad sends the load of the given clusterName from loadStore to the given server. If the server is not an empty string, and is different from the xds server, a new ClientConn will be created.

The same options used for creating the Client will be used (including NodeProto, and dial options if necessary).

It returns a function to cancel the load reporting stream. If server is different from xds server, the ClientConn will also be closed.

func (*Client) WatchCluster Uses

func (c *Client) WatchCluster(clusterName string, cdsCb func(CDSUpdate, error)) (cancel func())

WatchCluster uses CDS to discover information about the provided clusterName.

func (*Client) WatchEDS Uses

func (c *Client) WatchEDS(clusterName string, edsCb func(*EDSUpdate, error)) (cancel func())

WatchEDS watches the ghost.

func (*Client) WatchService Uses

func (c *Client) WatchService(serviceName string, callback func(ServiceUpdate, error)) (cancel func())

WatchService uses LDS and RDS protocols to discover information about the provided serviceName.

type ClusterLoadAssignmentBuilder Uses

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

ClusterLoadAssignmentBuilder builds a ClusterLoadAssignment, aka EDS response.

func NewClusterLoadAssignmentBuilder Uses

func NewClusterLoadAssignmentBuilder(clusterName string, dropPercents []uint32) *ClusterLoadAssignmentBuilder

NewClusterLoadAssignmentBuilder creates a ClusterLoadAssignmentBuilder.

func (*ClusterLoadAssignmentBuilder) AddLocality Uses

func (clab *ClusterLoadAssignmentBuilder) AddLocality(subzone string, weight uint32, priority uint32, addrsWithPort []string, opts *AddLocalityOptions)

AddLocality adds a locality to the builder.

func (*ClusterLoadAssignmentBuilder) Build Uses

func (clab *ClusterLoadAssignmentBuilder) Build() *xdspb.ClusterLoadAssignment

Build builds ClusterLoadAssignment.

type EDSUpdate Uses

type EDSUpdate struct {
    Drops      []OverloadDropConfig
    Localities []Locality
}

EDSUpdate contains an EDS update.

func ParseEDSRespProto Uses

func ParseEDSRespProto(m *xdspb.ClusterLoadAssignment) (*EDSUpdate, error)

ParseEDSRespProto turns EDS response proto message to EDSUpdate.

This is temporarily exported to be used in eds balancer, before it switches to use xds client. TODO: unexport.

func ParseEDSRespProtoForTesting Uses

func ParseEDSRespProtoForTesting(m *xdspb.ClusterLoadAssignment) *EDSUpdate

ParseEDSRespProtoForTesting parses EDS response, and panic if parsing fails. This is used by EDS balancer tests.

TODO: delete this. The EDS balancer should build an EDSUpdate directly,

instead of building and parsing a proto message.

type Endpoint Uses

type Endpoint struct {
    Address      string
    HealthStatus EndpointHealthStatus
    Weight       uint32
}

Endpoint contains information of an endpoint.

type EndpointHealthStatus Uses

type EndpointHealthStatus int32

EndpointHealthStatus represents the health status of an endpoint.

const (
    // EndpointHealthStatusUnknown represents HealthStatus UNKNOWN.
    EndpointHealthStatusUnknown EndpointHealthStatus = iota
    // EndpointHealthStatusHealthy represents HealthStatus HEALTHY.
    EndpointHealthStatusHealthy
    // EndpointHealthStatusUnhealthy represents HealthStatus UNHEALTHY.
    EndpointHealthStatusUnhealthy
    // EndpointHealthStatusDraining represents HealthStatus DRAINING.
    EndpointHealthStatusDraining
    // EndpointHealthStatusTimeout represents HealthStatus TIMEOUT.
    EndpointHealthStatusTimeout
    // EndpointHealthStatusDegraded represents HealthStatus DEGRADED.
    EndpointHealthStatusDegraded
)

type Locality Uses

type Locality struct {
    Endpoints []Endpoint
    ID        internal.Locality
    Priority  uint32
    Weight    uint32
}

Locality contains information of a locality.

type Options Uses

type Options struct {
    // Config contains a fully populated bootstrap config. It is the
    // responsibility of the caller to use some sane defaults here if the
    // bootstrap process returned with certain fields left unspecified.
    Config bootstrap.Config
    // DialOpts contains dial options to be used when dialing the xDS server.
    DialOpts []grpc.DialOption
}

Options provides all parameters required for the creation of an xDS client.

type OverloadDropConfig Uses

type OverloadDropConfig struct {
    Category    string
    Numerator   uint32
    Denominator uint32
}

OverloadDropConfig contains the config to drop overloads.

type ServiceUpdate Uses

type ServiceUpdate struct {
    Cluster string
}

ServiceUpdate contains update about the service.

Directories

PathSynopsis
bootstrapPackage bootstrap provides the functionality to initialize certain aspects of an xDS client by reading a bootstrap file.
fakexdsPackage fakexds provides a very basic fake implementation of the xDS server for unit testing purposes.

Package client imports 23 packages (graph) and is imported by 6 packages. Updated 2019-12-12. Refresh now. Tools for package owners.