Documentation ¶
Index ¶
- Variables
- func Register(name string, factory Factory)
- type ConsulClient
- type ConsulDiscovery
- func (c *ConsulDiscovery) DiscoverVTGate(ctx context.Context, tags []string) (*vtadminpb.VTGate, error)
- func (c *ConsulDiscovery) DiscoverVTGateAddr(ctx context.Context, tags []string) (string, error)
- func (c *ConsulDiscovery) DiscoverVTGates(ctx context.Context, tags []string) ([]*vtadminpb.VTGate, error)
- func (c *ConsulDiscovery) DiscoverVtctld(ctx context.Context, tags []string) (*vtadminpb.Vtctld, error)
- func (c *ConsulDiscovery) DiscoverVtctldAddr(ctx context.Context, tags []string) (string, error)
- func (c *ConsulDiscovery) DiscoverVtctlds(ctx context.Context, tags []string) ([]*vtadminpb.Vtctld, error)
- type ConsulHealth
- type Discovery
- type Factory
- type StaticFileClusterConfig
- type StaticFileDiscovery
- func (d *StaticFileDiscovery) DiscoverVTGate(ctx context.Context, tags []string) (*vtadminpb.VTGate, error)
- func (d *StaticFileDiscovery) DiscoverVTGateAddr(ctx context.Context, tags []string) (string, error)
- func (d *StaticFileDiscovery) DiscoverVTGates(ctx context.Context, tags []string) ([]*vtadminpb.VTGate, error)
- func (d *StaticFileDiscovery) DiscoverVtctld(ctx context.Context, tags []string) (*vtadminpb.Vtctld, error)
- func (d *StaticFileDiscovery) DiscoverVtctldAddr(ctx context.Context, tags []string) (string, error)
- func (d *StaticFileDiscovery) DiscoverVtctlds(ctx context.Context, tags []string) ([]*vtadminpb.Vtctld, error)
- type StaticFileVTGateConfig
- type StaticFileVtctldConfig
Constants ¶
This section is empty.
Variables ¶
var ( // ErrImplementationNotRegistered is returned from discovery.New if it is // called with an unknown implementation. ErrImplementationNotRegistered = errors.New("no discovery factory registered for implementation") // ErrNoVTGates should be returned from DiscoverVTGate* methods when they // are unable to find any vtgates for the given filter/query/tags. ErrNoVTGates = errors.New("no vtgates found") // ErrNoVtctlds should be returned from DiscoverVtctld* methods when they // are unable to find any vtctlds for the given filter/query/tags. ErrNoVtctlds = errors.New("no vtctlds found") )
Functions ¶
Types ¶
type ConsulClient ¶
type ConsulClient interface {
Health() ConsulHealth
}
ConsulClient defines an interface for the subset of the consul API used by discovery, so we can swap in an implementation for testing.
type ConsulDiscovery ¶
type ConsulDiscovery struct {
// contains filtered or unexported fields
}
ConsulDiscovery implements the Discovery interface for consul.
func (*ConsulDiscovery) DiscoverVTGate ¶
func (c *ConsulDiscovery) DiscoverVTGate(ctx context.Context, tags []string) (*vtadminpb.VTGate, error)
DiscoverVTGate is part of the Discovery interface.
func (*ConsulDiscovery) DiscoverVTGateAddr ¶
DiscoverVTGateAddr is part of the Discovery interface.
func (*ConsulDiscovery) DiscoverVTGates ¶
func (c *ConsulDiscovery) DiscoverVTGates(ctx context.Context, tags []string) ([]*vtadminpb.VTGate, error)
DiscoverVTGates is part of the Discovery interface.
func (*ConsulDiscovery) DiscoverVtctld ¶ added in v0.10.0
func (c *ConsulDiscovery) DiscoverVtctld(ctx context.Context, tags []string) (*vtadminpb.Vtctld, error)
DiscoverVtctld is part of the Discovery interface.
func (*ConsulDiscovery) DiscoverVtctldAddr ¶ added in v0.10.0
DiscoverVtctldAddr is part of the Discovery interface.
func (*ConsulDiscovery) DiscoverVtctlds ¶ added in v0.10.0
func (c *ConsulDiscovery) DiscoverVtctlds(ctx context.Context, tags []string) ([]*vtadminpb.Vtctld, error)
DiscoverVtctlds is part of the Discovery interface.
type ConsulHealth ¶
type ConsulHealth interface {
ServiceMultipleTags(service string, tags []string, passingOnly bool, q *consul.QueryOptions) ([]*consul.ServiceEntry, *consul.QueryMeta, error) // nolint:lll
}
ConsulHealth defines an interface for the subset of the (*consul.Health) struct used by discovery, so we can swap in an implementation for testing.
type Discovery ¶
type Discovery interface { // DiscoverVTGate returns a vtgate found in the discovery service. // Tags can optionally be used to filter the set of potential gates further. // Which gate in a set of found gates is returned is not specified by the // interface, and can be implementation-specific. DiscoverVTGate(ctx context.Context, tags []string) (*vtadminpb.VTGate, error) // DiscoverVTGateAddr returns the address of a of vtgate found in the // discovery service. Tags can optionally be used to filter the set of // potential gates further. Which gate in a set of found gates is used to // return an address is not specified by the interface, and can be // implementation-specific. DiscoverVTGateAddr(ctx context.Context, tags []string) (string, error) // DiscoverVTGates returns a list of vtgates found in the discovery service. // Tags can optionally be used to filter gates. Order of the gates is not // specified by the interface, and can be implementation-specific. DiscoverVTGates(ctx context.Context, tags []string) ([]*vtadminpb.VTGate, error) // DiscoverVtctld returns a vtctld found in the discovery service. // Tags can optionally be used to filter the set of potential vtctlds // further. Which vtctld in a set of found vtctlds is returned is not // specified by the interface, and can be implementation-specific. DiscoverVtctld(ctx context.Context, tags []string) (*vtadminpb.Vtctld, error) // DiscoverVtctldAddr returns the address of a vtctld found in the discovery // service. Tags can optionally be used to filter the set of potential // vtctlds further. Which vtctld in a set of potential vtctld is used to // return an address is not specified by the interface, and can be // implementation-specific. DiscoverVtctldAddr(ctx context.Context, tags []string) (string, error) // DiscoverVtctlds returns a list of vtctlds found in the discovery service. // Tags can optionally be used to filter vtctlds. Order of the vtctlds is // not specified by the interface, and can be implementation-specific. DiscoverVtctlds(ctx context.Context, tags []string) ([]*vtadminpb.Vtctld, error) }
Discovery defines the interface that service discovery plugins must implement. See ConsulDiscovery for an example implementation.
func New ¶
New returns a Discovery implementation using the registered factory for the implementation. Usage of the args slice is dependent on the implementation's factory.
type Factory ¶
type Factory func(cluster *vtadminpb.Cluster, flags *pflag.FlagSet, args []string) (Discovery, error)
Factory represents a function that can create a Discovery implementation. This package will provide several implementations and register them for use. The flags FlagSet is provided for convenience, but also to hint to plugin developers that they should expect the args to be in a format compatible with pflag.
type StaticFileClusterConfig ¶
type StaticFileClusterConfig struct { VTGates []*StaticFileVTGateConfig `json:"vtgates,omitempty"` Vtctlds []*StaticFileVtctldConfig `json:"vtctlds,omitempty"` }
StaticFileClusterConfig configures Vitess components for a single cluster.
type StaticFileDiscovery ¶
type StaticFileDiscovery struct {
// contains filtered or unexported fields
}
StaticFileDiscovery implements the Discovery interface for "discovering" Vitess components hardcoded in a static JSON file.
As an example, here's a minimal JSON file for a single Vitess cluster running locally (such as the one described in https://vitess.io/docs/get-started/local-docker):
{ "vtgates": [ { "host": { "hostname": "127.0.0.1:15991" } } ] }
For more examples of various static file configurations, see the unit tests.
func (*StaticFileDiscovery) DiscoverVTGate ¶
func (d *StaticFileDiscovery) DiscoverVTGate(ctx context.Context, tags []string) (*vtadminpb.VTGate, error)
DiscoverVTGate is part of the Discovery interface.
func (*StaticFileDiscovery) DiscoverVTGateAddr ¶
func (d *StaticFileDiscovery) DiscoverVTGateAddr(ctx context.Context, tags []string) (string, error)
DiscoverVTGateAddr is part of the Discovery interface.
func (*StaticFileDiscovery) DiscoverVTGates ¶
func (d *StaticFileDiscovery) DiscoverVTGates(ctx context.Context, tags []string) ([]*vtadminpb.VTGate, error)
DiscoverVTGates is part of the Discovery interface.
func (*StaticFileDiscovery) DiscoverVtctld ¶ added in v0.10.0
func (d *StaticFileDiscovery) DiscoverVtctld(ctx context.Context, tags []string) (*vtadminpb.Vtctld, error)
DiscoverVtctld is part of the Discovery interface.
func (*StaticFileDiscovery) DiscoverVtctldAddr ¶ added in v0.10.0
func (d *StaticFileDiscovery) DiscoverVtctldAddr(ctx context.Context, tags []string) (string, error)
DiscoverVtctldAddr is part of the Discovery interface.
func (*StaticFileDiscovery) DiscoverVtctlds ¶ added in v0.10.0
func (d *StaticFileDiscovery) DiscoverVtctlds(ctx context.Context, tags []string) ([]*vtadminpb.Vtctld, error)
DiscoverVtctlds is part of the Discovery interface.
type StaticFileVTGateConfig ¶
type StaticFileVTGateConfig struct { Host *vtadminpb.VTGate `json:"host"` Tags []string `json:"tags"` }
StaticFileVTGateConfig contains host and tag information for a single VTGate in a cluster.
type StaticFileVtctldConfig ¶ added in v0.10.0
type StaticFileVtctldConfig struct { Host *vtadminpb.Vtctld `json:"host"` Tags []string `json:"tags"` }
StaticFileVtctldConfig contains a host and tag information for a single Vtctld in a cluster.
Directories ¶
Path | Synopsis |
---|---|
Package fakediscovery provides a fake, in-memory discovery implementation.
|
Package fakediscovery provides a fake, in-memory discovery implementation. |