cluster

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cluster

type Cluster struct {
	ID        string
	Name      string
	Discovery discovery.Discovery

	// (TODO|@amason): after merging #7128, this still requires some additional
	// work, so deferring this for now!
	// vtctl vtctldclient.VtctldClient
	DB vtsql.DB
}

Cluster is the self-contained unit of services required for vtadmin to talk to a vitess cluster. This consists of a discovery service, a database connection, and a vtctl client.

func New

func New(cfg Config) (*Cluster, error)

New creates a new Cluster from a Config.

func (Cluster) ToProto

func (c Cluster) ToProto() *vtadminpb.Cluster

ToProto returns a value-copy protobuf equivalent of the cluster.

type ClustersFlag

type ClustersFlag map[string]Config

ClustersFlag implements flag.Value allowing multiple occurrences of a flag to be accumulated into a map.

func (*ClustersFlag) Set

func (cf *ClustersFlag) Set(value string) error

Set is part of the flag.Value interface. It merges the parsed config into the map, allowing ClustersFlag to power a repeated flag. See (*Config).Set for details on flag parsing.

func (*ClustersFlag) String

func (cf *ClustersFlag) String() string

String is part of the flag.Value interface.

func (*ClustersFlag) Type

func (cf *ClustersFlag) Type() string

Type is part of the pflag.Value interface.

type Config

type Config struct {
	ID                   string
	Name                 string
	DiscoveryImpl        string
	DiscoveryFlagsByImpl FlagsByImpl
	VtSQLFlags           map[string]string
}

Config represents the options to configure a vtadmin cluster.

func (Config) Cluster

func (cfg Config) Cluster() (*Cluster, error)

Cluster returns a new cluster instance from the given config.

func (Config) Merge

func (cfg Config) Merge(override Config) Config

Merge returns the result of merging the calling config into the passed config. Neither the caller or the argument are modified in any way.

func (*Config) Set

func (cfg *Config) Set(value string) error

Set is part of the flag.Value interface. Each flag is parsed according to the following DSN:

id= // ID or shortname of the cluster.
name= // Name of the cluster.
discovery= // Name of the discovery implementation
discovery-.*= // Per-discovery-implementation flags. These are passed to
              // a given discovery implementation's constructor.
vtsql-.*= // VtSQL-specific flags. Further parsing of these is delegated
          // to the vtsql package.

func (*Config) String

func (cfg *Config) String() string

String is part of the flag.Value interface.

func (*Config) Type

func (cfg *Config) Type() string

Type is part of the pflag.Value interface.

func (*Config) UnmarshalYAML

func (cfg *Config) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements the yaml.Unmarshaler interface.

type FileConfig

type FileConfig struct {
	Defaults Config
	Clusters map[string]Config
}

FileConfig represents the structure of a set of cluster configs on disk. It contains both a default config, and cluster-specific overrides. Currently only YAML config files are supported.

A valid config looks like:

defaults:
	discovery: k8s
clusters:
	clusterID1:
		name: clusterName1
		discovery-k8s-some-flag: some-val
	clusterID2:
		name: clusterName2
		discovery: consul

func (*FileConfig) Combine

func (fc *FileConfig) Combine(defaults Config, clusters map[string]Config) []Config

Combine combines a FileConfig with a default Config and a ClustersFlag (each defined on the command-line) into a slice of final Configs that are suitable to use for cluster creation.

Combination uses the following precedence: 1. Command-line cluster-specific overrides. 2. File-based cluster-specific overrides. 3. Command-line cluster defaults. 4. File-based cluster defaults.

func (*FileConfig) Set

func (fc *FileConfig) Set(value string) error

Set is part of the flag.Value interface. It loads the file configuration found at the path passed to the flag.

func (*FileConfig) String

func (fc *FileConfig) String() string

String is part of the flag.Value interface.

func (*FileConfig) Type

func (fc *FileConfig) Type() string

Type is part of the pflag.Value interface.

func (*FileConfig) UnmarshalYAML

func (fc *FileConfig) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML is part of the yaml.Unmarshaler interface.

type FlagsByImpl

type FlagsByImpl map[string]map[string]string

FlagsByImpl groups a set of flags by discovery implementation. Its mapping is impl_name=>flag=>value.

func (*FlagsByImpl) Merge

func (base *FlagsByImpl) Merge(override map[string]map[string]string)

Merge applies the flags in the parameter to the receiver, conflicts are resolved in favor of the parameter and not the receiver.

Directories

Path Synopsis
fakediscovery
Package fakediscovery provides a fake, in-memory discovery implementation.
Package fakediscovery provides a fake, in-memory discovery implementation.

Jump to

Keyboard shortcuts

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