...

Package fakeclient

import "google.golang.org/grpc/xds/internal/testutils/fakeclient"
Overview
Index

Overview ▾

Package fakeclient provides a fake implementation of an xDS client.

type Client

Client is a fake implementation of an xds client. It exposes a bunch of channels to signal the occurrence of various events.

type Client struct {
    // Embed XDSClient so this fake client implements the interface, but it's
    // never set (it's always nil). This may cause nil panic since not all the
    // methods are implemented.
    xdsclient.XDSClient
    // contains filtered or unexported fields
}

func NewClient

func NewClient() *Client

NewClient returns a new fake xds client.

func NewClientWithName

func NewClientWithName(name string) *Client

NewClientWithName returns a new fake xds client with the provided name. This is used in cases where multiple clients are created in the tests and we need to make sure the client is created for the expected balancer name.

func (*Client) BootstrapConfig

func (xdsC *Client) BootstrapConfig() *bootstrap.Config

BootstrapConfig returns the bootstrap config.

func (*Client) LoadStore

func (xdsC *Client) LoadStore() *load.Store

LoadStore returns the underlying load data store.

func (*Client) Name

func (xdsC *Client) Name() string

Name returns the name of the xds client.

func (*Client) ReportLoad

func (xdsC *Client) ReportLoad(server *bootstrap.ServerConfig) (loadStore *load.Store, cancel func())

ReportLoad starts reporting load about clusterName to server.

func (*Client) SetBootstrapConfig

func (xdsC *Client) SetBootstrapConfig(cfg *bootstrap.Config)

SetBootstrapConfig updates the bootstrap config.

func (*Client) WaitForCancelReportLoad

func (xdsC *Client) WaitForCancelReportLoad(ctx context.Context) error

WaitForCancelReportLoad waits for a load report to be cancelled and returns context.DeadlineExceeded otherwise.

func (*Client) WaitForReportLoad

func (xdsC *Client) WaitForReportLoad(ctx context.Context) (ReportLoadArgs, error)

WaitForReportLoad waits for ReportLoad to be invoked on this client and returns the arguments passed to it.

type ReportLoadArgs

ReportLoadArgs wraps the arguments passed to ReportLoad.

type ReportLoadArgs struct {
    // Server is the name of the server to which the load is reported.
    Server *bootstrap.ServerConfig
}