backendcluster

package
v1.4.0-nextgen.202510.7 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2026 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrBackendClusterNotFound = errors.New("backend cluster not found")

Functions

func ParseBackendID

func ParseBackendID(id string) (clusterName, addr string)

ParseBackendID parses the backendID into clusterName and addr. Please avoid using this function as much as possible, and only use it when you cannot find any other way to get the clusterName and addr. The backendID is designed to be opaque and should not be parsed in most cases.

Types

type Cluster

type Cluster struct {
	// contains filtered or unexported fields
}

Cluster is the cluster-scoped container for one backend PD cluster.

func NewCluster

func NewCluster(
	ctx context.Context,
	cfg *config.Config,
	clusterCfg config.BackendCluster,
	clusterTLS func() *tls.Config,
	logger *zap.Logger,
	cfgGetter config.ConfigGetter,
	metricsQuerier *MetricsQuerier,
) (*Cluster, error)

NewCluster creates a new Cluster instance based on the given configuration.

func (*Cluster) Close

func (c *Cluster) Close() error

func (*Cluster) Config

func (c *Cluster) Config() config.BackendCluster

func (*Cluster) DialContext

func (c *Cluster) DialContext(ctx context.Context, network, addr string) (net.Conn, error)

func (*Cluster) EtcdClient

func (c *Cluster) EtcdClient() *clientv3.Client

func (*Cluster) GetPromInfo

func (c *Cluster) GetPromInfo(ctx context.Context) (*infosync.PrometheusInfo, error)

func (*Cluster) GetTiDBTopology

func (c *Cluster) GetTiDBTopology(ctx context.Context) (map[string]*infosync.TiDBTopologyInfo, error)

func (*Cluster) HTTPClient

func (c *Cluster) HTTPClient() *httputil.Client

func (*Cluster) PreClose

func (c *Cluster) PreClose()

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

func NewManager

func NewManager(lg *zap.Logger, clusterTLS func() *tls.Config) *Manager

func (*Manager) Close

func (m *Manager) Close() error

func (*Manager) GetTiDBTopology

func (m *Manager) GetTiDBTopology(ctx context.Context) (map[string]*infosync.TiDBTopologyInfo, error)

func (*Manager) HasBackendClusters

func (m *Manager) HasBackendClusters() bool

func (*Manager) MetricsQuerier

func (m *Manager) MetricsQuerier() *MetricsQuerier

func (*Manager) NetworkRouter

func (m *Manager) NetworkRouter() *NetworkRouter

func (*Manager) PreClose

func (m *Manager) PreClose()

func (*Manager) PrimaryCluster

func (m *Manager) PrimaryCluster() *Cluster

PrimaryCluster returns the only configured cluster when the cluster count is exactly one. It exists for features that are only well-defined in the single-cluster case, such as VIP.

func (*Manager) Snapshot

func (m *Manager) Snapshot() map[string]*Cluster

func (*Manager) Start

func (m *Manager) Start(ctx context.Context, cfgGetter config.ConfigGetter, cfgCh <-chan *config.Config) error

type MetricsQuerier

type MetricsQuerier struct {
	// contains filtered or unexported fields
}

MetricsQuerier is a thin fan-out and merge view over cluster-scoped metrics readers. It does not own any metrics collection lifecycle by itself.

func NewMetricsQuerier

func NewMetricsQuerier(manager *Manager) *MetricsQuerier

func (*MetricsQuerier) AddQueryExpr

func (mq *MetricsQuerier) AddQueryExpr(key string, queryExpr metricsreader.QueryExpr, queryRule metricsreader.QueryRule)

func (*MetricsQuerier) GetBackendMetrics

func (mq *MetricsQuerier) GetBackendMetrics() []byte

func (*MetricsQuerier) GetBackendMetricsByCluster

func (mq *MetricsQuerier) GetBackendMetricsByCluster(clusterName string) []byte

func (*MetricsQuerier) GetQueryResult

func (mq *MetricsQuerier) GetQueryResult(key string) metricsreader.QueryResult

func (*MetricsQuerier) RemoveQueryExpr

func (mq *MetricsQuerier) RemoveQueryExpr(key string)

type NetworkRouter

type NetworkRouter struct {
	// contains filtered or unexported fields
}

NetworkRouter is a thin dispatch view over cluster-scoped dialers and HTTP clients. It does not own any cluster lifecycle by itself.

func NewNetworkRouter

func NewNetworkRouter(manager *Manager, clusterTLS func() *tls.Config) *NetworkRouter

func (*NetworkRouter) DialContext

func (nr *NetworkRouter) DialContext(ctx context.Context, network, addr, clusterName string) (net.Conn, error)

func (*NetworkRouter) HTTPClient

func (nr *NetworkRouter) HTTPClient(clusterName string) *httputil.Client

Jump to

Keyboard shortcuts

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