Documentation ¶
Index ¶
- func AnnotateSpan(c *Cluster, span trace.Span)
- type Cluster
- func (c *Cluster) FindAllShardsInKeyspace(ctx context.Context, keyspace string, opts FindAllShardsInKeyspaceOptions) (map[string]*vtctldatapb.Shard, error)
- func (c *Cluster) FindTablet(ctx context.Context, filter func(*vtadminpb.Tablet) bool) (*vtadminpb.Tablet, error)
- func (c *Cluster) FindTablets(ctx context.Context, filter func(*vtadminpb.Tablet) bool, n int) ([]*vtadminpb.Tablet, error)
- func (c *Cluster) FindWorkflows(ctx context.Context, keyspaces []string, opts FindWorkflowsOptions) (*vtadminpb.ClusterWorkflows, error)
- func (c *Cluster) GetSchema(ctx context.Context, keyspace string, opts GetSchemaOptions) (*vtadminpb.Schema, error)
- func (c *Cluster) GetTablets(ctx context.Context) ([]*vtadminpb.Tablet, error)
- func (c *Cluster) GetVSchema(ctx context.Context, keyspace string) (*vtadminpb.VSchema, error)
- func (c *Cluster) GetWorkflow(ctx context.Context, keyspace string, name string, opts GetWorkflowOptions) (*vtadminpb.Workflow, error)
- func (c *Cluster) GetWorkflows(ctx context.Context, keyspaces []string, opts GetWorkflowsOptions) (*vtadminpb.ClusterWorkflows, error)
- func (c Cluster) ToProto() *vtadminpb.Cluster
- type ClustersFlag
- type Config
- type FileConfig
- type FindAllShardsInKeyspaceOptions
- type FindWorkflowsOptions
- type FlagsByImpl
- type GetSchemaOptions
- type GetWorkflowOptions
- type GetWorkflowsOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AnnotateSpan ¶ added in v0.10.0
AnnotateSpan adds the cluster_id and cluster_name to a span.
Types ¶
type Cluster ¶
type Cluster struct { ID string Name string Discovery discovery.Discovery DB vtsql.DB Vtctld vtctldclient.Proxy }
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 (*Cluster) FindAllShardsInKeyspace ¶ added in v0.10.0
func (c *Cluster) FindAllShardsInKeyspace(ctx context.Context, keyspace string, opts FindAllShardsInKeyspaceOptions) (map[string]*vtctldatapb.Shard, error)
FindAllShardsInKeyspace proxies a FindAllShardsInKeyspace RPC to a cluster's vtctld, unpacking the response struct.
It can also optionally ensure the vtctldclient has a valid connection before making the RPC call.
func (*Cluster) FindTablet ¶ added in v0.10.0
func (c *Cluster) FindTablet(ctx context.Context, filter func(*vtadminpb.Tablet) bool) (*vtadminpb.Tablet, error)
FindTablet returns the first tablet in a given cluster that satisfies the filter function.
func (*Cluster) FindTablets ¶ added in v0.10.0
func (c *Cluster) FindTablets(ctx context.Context, filter func(*vtadminpb.Tablet) bool, n int) ([]*vtadminpb.Tablet, error)
FindTablets returns the first N tablets in the given cluster that satisfy the filter function. If N = -1, then all matching tablets are returned. Ordering is not guaranteed, and callers should write their filter functions accordingly.
func (*Cluster) FindWorkflows ¶ added in v0.10.0
func (c *Cluster) FindWorkflows(ctx context.Context, keyspaces []string, opts FindWorkflowsOptions) (*vtadminpb.ClusterWorkflows, error)
FindWorkflows returns a list of Workflows in this cluster, across the given keyspaces and filtering according to the options passed in.
If the list of keyspaces to check is empty, then FindWorkflows will use the result of GetKeyspaces to search all keyspaces in the cluster. In this case, opts.IgnoreKeyspaces is respected.
Callers should use this function when they want more fine-grained filtering, and GetWorkflows when they just want to filter on keyspace name.
Note that if only a subset of keyspaces error on their vtctld GetWorkflows rpc, this is treated as a partial success, and the ClusterWorkflows response will include any errors in the Warnings slice. If all keyspaces fail, or if non-(Vtctld.GetWorkflows) calls fail, this is treated as an error by this function.
func (*Cluster) GetSchema ¶ added in v0.10.0
func (c *Cluster) GetSchema(ctx context.Context, keyspace string, opts GetSchemaOptions) (*vtadminpb.Schema, error)
GetSchema returns the schema for a given keyspace. GetSchema has a few different behaviors depending on the GetSchemaOptions provided, as follows:
(1) If opts.Tablets is empty, we will first use FindTablets to fetch all tablets for the keyspace, regardless of their serving state. Additional filtering of either this set, or the provided Tablets, will happen later.
(2) If opts.SizeOpts.AggregateSizes is true, we will also make a call to FindAllShardsInKeyspace, in order to fan out GetSchema RPCs to a tablet in each shard. If this option is false, we make exactly one GetSchema request to a single, randomly-chosen, tablet in the keyspace.
(3) We will only make GetSchema RPCs to tablets that are in SERVING state; we don't want to use a tablet that might be in a bad state as the source of truth for a schema. Therefore if we can't find a SERVING tablet for the keyspace (in non-aggregation mode) or for a shard in that keyspace (in aggregation mode), then we will return an error back to the caller.
func (*Cluster) GetTablets ¶ added in v0.10.0
GetTablets returns all tablets in the cluster.
func (*Cluster) GetVSchema ¶ added in v0.10.0
GetVSchema returns the vschema for a given keyspace in this cluster. The caller is responsible for making at least one call to c.Vtctld.Dial prior to calling this function.
func (*Cluster) GetWorkflow ¶ added in v0.10.0
func (c *Cluster) GetWorkflow(ctx context.Context, keyspace string, name string, opts GetWorkflowOptions) (*vtadminpb.Workflow, error)
GetWorkflow returns the single Workflow in this cluster for the given keyspace and workflow name. It returns an error if either no workflows or multiple workflows are found.
func (*Cluster) GetWorkflows ¶ added in v0.10.0
func (c *Cluster) GetWorkflows(ctx context.Context, keyspaces []string, opts GetWorkflowsOptions) (*vtadminpb.ClusterWorkflows, error)
GetWorkflows returns a list of Workflows in this cluster, across the given keyspaces and filtering according to the options passed in.
If the list of keyspaces to check is empty, then GetWorkflows will use the result of GetKeyspaces to search all keyspaces in the cluster. In this case, opts.IgnoreKeyspaces is respected.
type ClustersFlag ¶
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 VtctldFlags map[string]string }
Config represents the options to configure a vtadmin cluster.
func (Config) Merge ¶
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 ¶
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) UnmarshalYAML ¶
UnmarshalYAML implements the yaml.Unmarshaler interface.
type FileConfig ¶
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 FindAllShardsInKeyspaceOptions ¶ added in v0.10.0
type FindAllShardsInKeyspaceOptions struct { // SkipDial indicates that the cluster can assume the vtctldclient has // already dialed up a connection to a vtctld. SkipDial bool }
FindAllShardsInKeyspaceOptions modify the behavior of a cluster's FindAllShardsInKeyspace method.
type FindWorkflowsOptions ¶ added in v0.10.0
type FindWorkflowsOptions struct { ActiveOnly bool IgnoreKeyspaces sets.String Filter func(workflow *vtadminpb.Workflow) bool }
FindWorkflowsOptions is the set of options for FindWorkflows requests.
type FlagsByImpl ¶
FlagsByImpl groups a set of flags by discovery implementation. Its mapping is impl_name=>flag=>value.
type GetSchemaOptions ¶ added in v0.10.0
type GetSchemaOptions struct { // Tablets is the starting set of tablets that GetSchema will filter to find // suitable tablet(s) to make GetSchema RPC(s) to. // // If empty, GetSchema will first call (*Cluster).FindTablets() to fetch all // tablets for the keyspace. Tablets []*vtadminpb.Tablet // BaseRequest is used to share some common parameters to use for the // individual tablet GetSchema RPCs made by (*Cluster).GetSchema, which // takes a copy of this request in order to makeb certain overrides as // needed, so these mutations are transparent to the caller. // // The TabletAlias field is ignored completely by (*Cluster).GetSchema, as // it is overwritten for each tablet RPC that method makes. // // The TableSizesOnly field is overwritten only in certain tablet RPCs when // SizeOpts.AggregateSizes is true. In order to move minimal bytes over the // wire, we assume that schema definitions match across all shards, so we // can get the full schema from just one tablet, and then just the table // size information from the other N-1 tablets. // // The TableNamesOnly field is untouched by (*Cluster).GetSchema when not // doing size aggregation. However, when doing size aggregation, if // TableNamesOnly is true, we log a warning and override it. This is because // TableNamesOnly is mutually exclusive with TableSizesOnly, and size // aggregation requires setting TableSizesOnly in the cases described above. BaseRequest *vtctldatapb.GetSchemaRequest // TableSizeOptions control whether the (*Cluster).GetSchema method performs // cross-shard table size aggregation (via the AggregateSizes field). // // If the AggregateSizes field is false, the rest of this struct is ignored, // no size aggregation is done, and (*Cluster).GetSchema will make exactly // one GetSchema RPC to a SERVING tablet in the keyspace. // // If the AggregateSizes field is true, (*Cluster).GetSchema will make a // FindAllShardsInKeyspace vtctld RPC, and then filter the given Tablets // (described above) to find one SERVING tablet for each shard in the // keyspace, skipping any non-serving shards in the keyspace. TableSizeOptions *vtadminpb.GetSchemaTableSizeOptions }
GetSchemaOptions contains the options that modify the behavior of the (*Cluster).GetSchema method.
type GetWorkflowOptions ¶ added in v0.10.0
type GetWorkflowOptions struct {
ActiveOnly bool
}
GetWorkflowOptions is the set of filtering options for GetWorkflow requests.
type GetWorkflowsOptions ¶ added in v0.10.0
GetWorkflowsOptions is the set of filtering options for GetWorkflows requests.
Directories ¶
Path | Synopsis |
---|---|
fakediscovery
Package fakediscovery provides a fake, in-memory discovery implementation.
|
Package fakediscovery provides a fake, in-memory discovery implementation. |