Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { Credentials Credentials // CredentialsPath is used only to power vtadmin debug endpoints; there may // be a better way where we don't need to put this in the config, because // it's not really an "option" in normal use. CredentialsPath string Cluster *vtadminpb.Cluster ResolverOptions *resolver.Options // contains filtered or unexported fields }
Config represents the options that modify the behavior of a vtqsl.VTGateProxy.
type ConfigOption ¶ added in v0.14.0
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(c vitessdriver.Configuration) (*sql.DB, 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 (for example, package vtadmin/cluster).
type Credentials ¶
type Credentials interface { // GetEffectiveUsername returns the username on whose behalf the DB is // issuing queries. GetEffectiveUsername() string // GetUsername returns the immediate username for a DB connection. GetUsername() string credentials.PerRPCCredentials }
Credentials defines the interface needed for vtsql properly connect to and query Vitess databases.
type DB ¶
type DB interface { // ShowTablets executes `SHOW vitess_tablets` and returns the result. ShowTablets(ctx context.Context) (*sql.Rows, error) // Ping behaves like (*sql.DB).Ping. Ping() error // PingContext behaves like (*sql.DB).PingContext. PingContext(ctx context.Context) error // Close closes the underlying database connection. This is a no-op if // the DB has no current valid connection. It is safe to call repeatedly. // // Once closed, a DB is not safe for reuse. Close() error }
DB defines the connection and query interface of vitess SQL queries used by VTAdmin clusters.
type StaticAuthCredentials ¶
type StaticAuthCredentials struct { *grpcclient.StaticAuthClientCreds EffectiveUser string }
StaticAuthCredentials augments a grpcclient.StaticAuthClientCreds with an effective username.
func (*StaticAuthCredentials) GetEffectiveUsername ¶
func (creds *StaticAuthCredentials) GetEffectiveUsername() string
GetEffectiveUsername is part of the Credentials interface.
func (*StaticAuthCredentials) GetUsername ¶
func (creds *StaticAuthCredentials) GetUsername() string
GetUsername is part of the Credentials interface.
type VTGateProxy ¶
type VTGateProxy struct {
// contains filtered or unexported fields
}
VTGateProxy is a proxy for creating and using database connections to vtgates in a Vitess cluster.
func New ¶
func New(ctx context.Context, cfg *Config) (*VTGateProxy, error)
New returns a VTGateProxy to the given cluster. When Dial-ing, it will use the given discovery implementation to find a vtgate 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 vtgate; users must call Dial before first use.
func (*VTGateProxy) Close ¶
func (vtgate *VTGateProxy) Close() error
Close is part of the DB interface and satisfies io.Closer.
func (*VTGateProxy) Debug ¶ added in v0.12.0
func (vtgate *VTGateProxy) Debug() map[string]any
Debug implements debug.Debuggable for VTGateProxy.
func (*VTGateProxy) Ping ¶
func (vtgate *VTGateProxy) Ping() error
Ping is part of the DB interface.
func (*VTGateProxy) PingContext ¶
func (vtgate *VTGateProxy) PingContext(ctx context.Context) error
PingContext is part of the DB interface.
func (*VTGateProxy) ShowTablets ¶
ShowTablets is part of the DB interface.