vtctldclient

package
v0.18.7 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2024 License: Apache-2.0 Imports: 20 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
	// 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(ctx context.Context, cfg *Config) (*ClientProxy, error)

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) Debug added in v0.12.0

func (vtctld *ClientProxy) Debug() map[string]any

Debug implements debug.Debuggable for ClientProxy.

type Config

type Config struct {
	Credentials     *grpcclient.StaticAuthClientCreds
	CredentialsPath string

	Cluster *vtadminpb.Cluster

	ResolverOptions *resolver.Options
	// contains filtered or unexported fields
}

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 ConfigOption added in v0.14.0

type ConfigOption func(cfg *Config) *Config

ConfigOption is a function that mutates a Config. It should return the same Config structure, in a builder-pattern style.

func WithDialFunc added in v0.14.0

func WithDialFunc(f func(addr string, ff grpcclient.FailFast, opts ...grpc.DialOption) (vtctldclient.VtctldClient, error)) ConfigOption

WithDialFunc returns a ConfigOption that applies the given dial function to a Config.

It is used to support dependency injection in tests, and needs to be exported for higher-level tests (via vtadmin/testutil).

type Proxy

type Proxy interface {
	// 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.
	//
	// Once closed, a proxy is not safe for reuse.
	Close() error

	vtctlservicepb.VtctldClient
}

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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