mysql

package
v0.18.6 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SelfInstanceKey = &InstanceKey{Hostname: "(self)", Port: 1}

SelfInstanceKey is a special indicator for "this instance", e.g. denoting the MySQL server associated with local tablet The values of this key are immaterial and are intentionally descriptive

Functions

This section is empty.

Types

type ClusterInstanceKey

type ClusterInstanceKey struct {
	ClusterName string
	Key         InstanceKey
}

ClusterInstanceKey combines a cluster name with an instance key

func GetClusterInstanceKey

func GetClusterInstanceKey(clusterName string, key *InstanceKey) ClusterInstanceKey

GetClusterInstanceKey creates a ClusterInstanceKey object

type ClusterProbes

type ClusterProbes struct {
	ClusterName          string
	IgnoreHostsCount     int
	IgnoreHostsThreshold float64
	InstanceProbes       *Probes
}

ClusterProbes has the probes for a specific cluster

type InstanceKey

type InstanceKey struct {
	Hostname string
	Port     int
}

InstanceKey is an instance indicator, identified by hostname and port

func ParseInstanceKey

func ParseInstanceKey(hostPort string, defaultPort int) (*InstanceKey, error)

ParseInstanceKey will parse an InstanceKey from a string representation such as 127.0.0.1:3306 or some.hostname `defaultPort` is used if `hostPort` does not include a port.

func (*InstanceKey) DisplayString

func (i *InstanceKey) DisplayString() string

DisplayString returns a user-friendly string representation of this key

func (*InstanceKey) Equals

func (i *InstanceKey) Equals(other *InstanceKey) bool

Equals tests equality between this key and another key

func (*InstanceKey) IsSelf added in v0.10.0

func (i *InstanceKey) IsSelf() bool

IsSelf checks if this is the special "self" instance key

func (*InstanceKey) IsValid

func (i *InstanceKey) IsValid() bool

IsValid uses simple heuristics to see whether this key represents an actual instance

func (*InstanceKey) SmallerThan

func (i *InstanceKey) SmallerThan(other *InstanceKey) bool

SmallerThan returns true if this key is dictionary-smaller than another. This is used for consistent sorting/ordering; there's nothing magical about it.

func (InstanceKey) String

func (i InstanceKey) String() string

String returns a user-friendly string representation of this key

func (*InstanceKey) StringCode

func (i *InstanceKey) StringCode() string

StringCode returns an official string representation of this key

type InstanceMetricResultMap

type InstanceMetricResultMap map[ClusterInstanceKey]base.MetricResult

InstanceMetricResultMap maps a cluster-instance to a result

type Inventory

type Inventory struct {
	ClustersProbes       map[string](*Probes)
	IgnoreHostsCount     map[string]int
	IgnoreHostsThreshold map[string]float64
	InstanceKeyMetrics   InstanceMetricResultMap
}

Inventory has the operational data about probes, their metrics, and relevant configuration

func NewInventory

func NewInventory() *Inventory

NewInventory creates a Inventory

type MetricsQueryType added in v0.10.0

type MetricsQueryType int

MetricsQueryType indicates the type of metrics query on MySQL backend. See following.

const (
	// MetricsQueryTypeDefault indictes the default, internal implementation. Specifically, our throttler runs a replication lag query
	MetricsQueryTypeDefault MetricsQueryType = iota
	// MetricsQueryTypeShowGlobal indicatesa SHOW GLOBAL (STATUS|VARIABLES) query
	MetricsQueryTypeShowGlobal
	// MetricsQueryTypeSelect indicates a custom SELECT query
	MetricsQueryTypeSelect
	// MetricsQueryTypeUnknown is an unknown query type, which we cannot run. This is an error
	MetricsQueryTypeUnknown
)

func GetMetricsQueryType added in v0.10.0

func GetMetricsQueryType(query string) MetricsQueryType

GetMetricsQueryType analyzes the type of a metrics query

type MySQLThrottleMetric

type MySQLThrottleMetric struct {
	ClusterName string
	Key         InstanceKey
	Value       float64
	Err         error
}

MySQLThrottleMetric has the probed metric for a mysql instance

func NewMySQLThrottleMetric

func NewMySQLThrottleMetric() *MySQLThrottleMetric

NewMySQLThrottleMetric creates a new MySQLThrottleMetric

func ReadThrottleMetric

func ReadThrottleMetric(probe *Probe, clusterName string, overrideGetMetricFunc func() *MySQLThrottleMetric) (mySQLThrottleMetric *MySQLThrottleMetric)

ReadThrottleMetric returns a metric for the given probe. Either by explicit query or via SHOW REPLICA STATUS

func (*MySQLThrottleMetric) Get

func (metric *MySQLThrottleMetric) Get() (float64, error)

Get implements MetricResult

func (*MySQLThrottleMetric) GetClusterInstanceKey

func (metric *MySQLThrottleMetric) GetClusterInstanceKey() ClusterInstanceKey

GetClusterInstanceKey returns the ClusterInstanceKey part of the metric

type Probe

type Probe struct {
	Key             InstanceKey
	MetricQuery     string
	Tablet          *topodatapb.Tablet
	TabletHost      string
	TabletPort      int
	CacheMillis     int
	QueryInProgress int64
}

Probe is the minimal configuration required to connect to a MySQL server

func NewProbe

func NewProbe() *Probe

NewProbe creates Probe

func (*Probe) Equals

func (p *Probe) Equals(other *Probe) bool

Equals checks if this probe has same instance key as another

func (*Probe) String

func (p *Probe) String() string

String returns a human readable string of this struct

type Probes

type Probes map[InstanceKey](*Probe)

Probes maps instances to probe(s)

func NewProbes

func NewProbes() *Probes

NewProbes creates Probes

Jump to

Keyboard shortcuts

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