kv

package
v0.0.0-...-c428d36 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2024 License: Apache-2.0 Imports: 43 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateTiStore

func CreateTiStore(urls string, credential *security.Credential) (tidbkv.Storage, error)

CreateTiStore creates a tikv storage client Note: It will return a same storage if the urls connect to a same pd cluster, so must be careful when you call storage.Close().

func GetGlobalGrpcMetrics

func GetGlobalGrpcMetrics() *grpc_prometheus.ClientMetrics

GetGlobalGrpcMetrics gets the global grpc metrics.

func GetSnapshotMeta

func GetSnapshotMeta(tiStore tidbkv.Storage, ts uint64) *meta.Meta

GetSnapshotMeta returns tidb meta information

func InitMetrics

func InitMetrics(registry *prometheus.Registry)

InitMetrics registers all metrics in the kv package

Types

type GrpcPool

type GrpcPool interface {
	// GetConn returns an available gRPC ClientConn
	GetConn(target string) (*sharedConn, error)

	// ReleaseConn is called when a gRPC stream is released
	ReleaseConn(sc *sharedConn, target string)

	// RecycleConn recycles idle connections periodically
	RecycleConn(ctx context.Context)

	// Close tears down all ClientConns maintained in pool
	Close()
}

GrpcPool defines an interface that can serve as a gPRC connection pool. It provides API to get a shared connection from pool and API to decrease usage reference of the shared connection

type GrpcPoolImpl

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

GrpcPoolImpl implement GrpcPool interface

func NewGrpcPoolImpl

func NewGrpcPoolImpl(ctx context.Context, credential *security.Credential) *GrpcPoolImpl

NewGrpcPoolImpl creates a new GrpcPoolImpl instance

func (*GrpcPoolImpl) Close

func (pool *GrpcPoolImpl) Close()

Close implements GrpcPool.Close

func (*GrpcPoolImpl) GetConn

func (pool *GrpcPoolImpl) GetConn(addr string) (*sharedConn, error)

GetConn implements GrpcPool.GetConn

func (*GrpcPoolImpl) RecycleConn

func (pool *GrpcPoolImpl) RecycleConn(ctx context.Context)

RecycleConn implements GrpcPool.RecycleConn

func (*GrpcPoolImpl) ReleaseConn

func (pool *GrpcPoolImpl) ReleaseConn(sc *sharedConn, addr string)

ReleaseConn implements GrpcPool.ReleaseConn

type MultiplexingEvent

type MultiplexingEvent struct {
	model.RegionFeedEvent
	SubscriptionID SubscriptionID
	Start          time.Time
}

MultiplexingEvent wrap a region event with SubscriptionID to indicate which subscription it belongs to.

type SharedClient

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

SharedClient is shared by many tables to pull events from TiKV. All exported Methods are thread-safe.

func NewSharedClient

func NewSharedClient(
	changefeed model.ChangeFeedID,
	cfg *config.ServerConfig,
	filterLoop bool,
	pd pd.Client,
	grpcPool *sharedconn.ConnAndClientPool,
	regionCache *tikv.RegionCache,
	pdClock pdutil.Clock,
	lockResolver txnutil.LockResolver,
) *SharedClient

NewSharedClient creates a client.

func (*SharedClient) AllocSubscriptionID

func (s *SharedClient) AllocSubscriptionID() SubscriptionID

AllocSubscriptionID gets an ID can be used in `Subscribe`.

func (*SharedClient) Close

func (s *SharedClient) Close()

Close closes the client. Must be called after `Run` returns.

func (*SharedClient) RegionCount

func (s *SharedClient) RegionCount(subID SubscriptionID) uint64

RegionCount returns subscribed region count for the span.

func (*SharedClient) ResolveLock

func (s *SharedClient) ResolveLock(subID SubscriptionID, targetTs uint64)

ResolveLock is a function. If outsider subscribers find a span resolved timestamp is advanced slowly or stopped, they can try to resolve locks in the given span.

func (*SharedClient) Run

func (s *SharedClient) Run(ctx context.Context) error

Run the client.

func (*SharedClient) Subscribe

func (s *SharedClient) Subscribe(subID SubscriptionID, span tablepb.Span, startTs uint64, eventCh chan<- MultiplexingEvent)

Subscribe the given table span. NOTE: `span.TableID` must be set correctly. It new a subscribedTable and store it in `s.totalSpans`, and send a rangeTask to `s.rangeTaskCh`. The rangeTask will be handled in `handleRangeTasks` goroutine.

func (*SharedClient) Unsubscribe

func (s *SharedClient) Unsubscribe(subID SubscriptionID)

Unsubscribe the given table span. All covered regions will be deregistered asynchronously. NOTE: `span.TableID` must be set correctly.

type SubscriptionID

type SubscriptionID uint64

SubscriptionID comes from `SharedClient.AllocSubscriptionID`.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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