vtctldclient

package
v0.10.4 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2021 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClientProxy

type ClientProxy struct {
	vtctldclient.VtctldClient // embedded to provide easy implementation of the vtctlservicepb.VtctldClient interface

	// DialFunc is called to open a new vtctdclient connection. In production,
	// this should always be grpcvtctldclient.NewWithDialOpts, but it is
	// exported for testing purposes.
	DialFunc func(addr string, ff grpcclient.FailFast, opts ...grpc.DialOption) (vtctldclient.VtctldClient, error)
	// contains filtered or unexported fields
}

ClientProxy implements the Proxy interface relying on a discovery.Discovery implementation to handle vtctld discovery and connection management.

func New

func New(cfg *Config) *ClientProxy

New returns a ClientProxy to the given cluster. When Dial-ing, it will use the given discovery implementation to find a vtctld to connect to, and the given creds to dial the underlying gRPC connection, both of which are provided by the Config.

It does not open a connection to a vtctld; users must call Dial before first use.

func (*ClientProxy) Close

func (vtctld *ClientProxy) Close() error

Close is part of the Proxy interface.

func (*ClientProxy) Dial

func (vtctld *ClientProxy) Dial(ctx context.Context) error

Dial is part of the Proxy interface.

func (*ClientProxy) Hostname

func (vtctld *ClientProxy) Hostname() string

Hostname is part of the Proxy interface.

type Config

type Config struct {
	Discovery   discovery.Discovery
	Credentials *grpcclient.StaticAuthClientCreds

	CredentialsPath string

	Cluster *vtadminpb.Cluster
}

Config represents the options that modify the behavior of a Proxy.

func Parse

func Parse(cluster *vtadminpb.Cluster, disco discovery.Discovery, args []string) (*Config, error)

Parse returns a new config with the given cluster and discovery, after attempting to parse the command-line pflags into that Config. See (*Config).Parse() for more details.

func (*Config) Parse

func (c *Config) Parse(args []string) error

Parse reads options specified as command-line pflags (--key=value, note the double-dash!) into a Config. It is meant to be called from (*cluster.Cluster).New().

type Proxy

type Proxy interface {
	// Dial opens a gRPC connection to a vtctld in the cluster. If the Proxy
	// already has a valid connection, this is a no-op.
	Dial(ctx context.Context) error

	// Hostname returns the hostname the Proxy is currently connected to.
	Hostname() string

	// Close closes the underlying vtctldclient connection. This is a no-op if
	// the Proxy has no current, valid connection. It is safe to call repeatedly.
	// Users may call Dial on a previously-closed Proxy to create a new
	// connection, but that connection may not be to the same particular vtctld.
	Close() error

	vtctlservicepb.VtctldClient
}

Proxy defines the connection interface of a proxied vtctldclient used by VTAdmin clusters.

Jump to

Keyboard shortcuts

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