resolver

package
v0.21.0 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package resolver provides a discovery-based resolver for VTAdmin clusters.

It uses a discovery.Discovery implementation to dynamically update the set of vtctlds and vtgates in a cluster being used by a grpc.ClientConn, allowing VTAdmin to transparently reconnect to different vtctlds and vtgates both periodically and when hosts are recycled.

Some potential improvements we can add, if desired:

1. Stats!

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DialAddr

func DialAddr(resolver grpcresolver.Builder, component string) string

DialAddr returns the dial address for a resolver scheme and component.

VtctldClientProxy and VTGateProxy should use this to ensure their Dial calls use their respective discovery resolvers.

Types

type BalancerPolicy

type BalancerPolicy string

BalancerPolicy is an enum for different grpc load balancer policies. It also implements the pflag.Value interface to be used as a flagset Var destination.

const (
	// PickFirstBalancer
	PickFirstBalancer  BalancerPolicy = "pick_first"
	RoundRobinBalancer BalancerPolicy = "round_robin"
)

func (*BalancerPolicy) Set

func (bp *BalancerPolicy) Set(s string) error

Set is part of the pflag.Value interface.

func (*BalancerPolicy) String

func (bp *BalancerPolicy) String() string

String is part of the pflag.Value interface.

func (*BalancerPolicy) Type

func (*BalancerPolicy) Type() string

Type is part of the pflag.Value interface.

type Options

type Options struct {
	// Discovery is the discovery implementation used to discover host addresses
	// when the ClientConn requests an update from the resolver.
	Discovery        discovery.Discovery
	DiscoveryTags    []string
	DiscoveryTimeout time.Duration

	// MinDiscoveryInterval is the minimum amount of time to wait before re-
	// discovering after a successful discovery resolution. This is useful to
	// avoid spamming the backing discovery service if multiple ResolveNow calls
	// are made in rapid succession.
	//
	// Note that the interval for failed discovery resolutions are governed by
	// the backoff strategy and configuration, not this field.
	MinDiscoveryInterval time.Duration

	// BackoffStrategy specfies the strategy to use when backing off of failed
	// discovery resolution. Permitted values are "exponential", "linear", and
	// "none"; the empty string defaults to "exponential".
	BackoffStrategy string
	// BackoffConfig is the configuration used by the given backoff strategy.
	// For a "none" strategy, this is ignored.
	BackoffConfig grpcbackoff.Config

	// BalancerPolicy, if set, will cause a resolver to provide a ServiceConfig
	// to the resolver's ClientConn with a corresponding loadBalancingConfig.
	// Omitting this option will cause grpc to use its default load balacing
	// policy, which is currently pick_first.
	//
	// For more details, see https://github.com/grpc/grpc/blob/master/doc/service_config.md.
	BalancerPolicy BalancerPolicy
}

Options defines the configuration options that can produce a resolver.Builder.

A builder may be produced directly from an Options struct, but the intended usage is to first initialize an Options struct via opts.InstallFlags, which ensures the Options have sensible defaults and both vtctldclient proxy and VTGateProxy do.

func (*Options) InstallFlags

func (opts *Options) InstallFlags(fs *pflag.FlagSet)

InstallFlags installs the resolver.Options flags on the given flagset. It is used by both vtsql and vtctldclient proxies.

func (*Options) NewBuilder

func (opts *Options) NewBuilder(scheme string) grpcresolver.Builder

NewBuilder returns a gRPC resolver.Builder for the given scheme. For vtadmin, the scheme should be a cluster ID.

The target provided to Builder.Build will be used to switch on vtctld or vtgate, based on the URL.Host field of the parsed dial target. This means that the addr passed to Dial should have the form "{clusterID}://{vtctld|vtgate}/". Other target URL hosts will cause an error. To ensure the dial address conforms to this constraint, use this package's DialAddr function.

Jump to

Keyboard shortcuts

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