conn

package
v0.0.0-...-a345a4b Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2024 License: Apache-2.0, Apache-2.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetAllTiKVStores

func GetAllTiKVStores(
	ctx context.Context,
	pdClient pd.Client,
	storeBehavior StoreBehavior,
) ([]*metapb.Store, error)

GetAllTiKVStores returns all TiKV stores registered to the PD client. The stores must not be a tombstone and must never contain a label `engine=tiflash`.

func GetAllTiKVStoresWithRetry

func GetAllTiKVStoresWithRetry(ctx context.Context,
	pdClient pd.Client,
	storeBehavior StoreBehavior,
) ([]*metapb.Store, error)

func GetTiKVApiVersion

func GetTiKVApiVersion(ctx context.Context, pdClient pd.Client, tlsConf *tls.Config) (kvrpcpb.APIVersion, error)

Types

type Mgr

type Mgr struct {
	*pdutil.PdController
	// contains filtered or unexported fields
}

Mgr manages connections to a TiDB cluster.

func NewMgr

func NewMgr(
	ctx context.Context,
	g glue.Glue,
	pdAddrs string,
	tlsConf *tls.Config,
	securityOption pd.SecurityOption,
	keepalive keepalive.ClientParameters,
	storeBehavior StoreBehavior,
	checkRequirements bool,
) (*Mgr, error)

NewMgr creates a new Mgr.

initializing Domain.

func (*Mgr) Close

func (mgr *Mgr) Close()

Close closes all client in Mgr.

func (*Mgr) GetBackupClient

func (mgr *Mgr) GetBackupClient(ctx context.Context, storeID uint64) (backuppb.BackupClient, error)

GetBackupClient get or create a backup client.

func (*Mgr) GetLockResolver

func (mgr *Mgr) GetLockResolver() *txnlock.LockResolver

GetLockResolver gets the LockResolver.

func (*Mgr) GetTLSConfig

func (mgr *Mgr) GetTLSConfig() *tls.Config

GetTLSConfig returns the tls config.

func (*Mgr) ResetBackupClient

func (mgr *Mgr) ResetBackupClient(ctx context.Context, storeID uint64) (backuppb.BackupClient, error)

ResetBackupClient reset the connection for backup client.

type Pool

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

Pool is a lazy pool of gRPC channels. When `Get` called, it lazily allocates new connection if connection not full. If it's full, then it will return allocated channels round-robin.

func NewConnPool

func NewConnPool(cap int, newConn func(ctx context.Context) (*grpc.ClientConn, error)) *Pool

NewConnPool creates a new Pool by the specified conn factory function and capacity.

func (*Pool) Close

func (p *Pool) Close()

Close closes the conn pool.

func (*Pool) Get

func (p *Pool) Get(ctx context.Context) (*grpc.ClientConn, error)

Get tries to get an existing connection from the pool, or make a new one if the pool not full.

type StorageConfig

type StorageConfig struct {
	APIVersion int  `json:"api-version"`
	EnableTTL  bool `json:"enable-ttl"`
}

type StoreBehavior

type StoreBehavior uint8

StoreBehavior is the action to do in GetAllTiKVStores when a non-TiKV store (e.g. TiFlash store) is found.

const (
	// ErrorOnTiFlash causes GetAllTiKVStores to return error when the store is
	// found to be a TiFlash node.
	ErrorOnTiFlash StoreBehavior = 0
	// SkipTiFlash causes GetAllTiKVStores to skip the store when it is found to
	// be a TiFlash node.
	SkipTiFlash StoreBehavior = 1
	// TiFlashOnly caused GetAllTiKVStores to skip the store which is not a
	// TiFlash node.
	TiFlashOnly StoreBehavior = 2
)

type StoreConfig

type StoreConfig struct {
	Storage StorageConfig `json:"storage"`
}

Jump to

Keyboard shortcuts

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