kv

package
v0.0.0-...-1b33b2a Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2024 License: Apache-2.0 Imports: 45 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NewCDCKVClient = NewCDCClient

NewCDCKVClient is the constructor of CDC KV client

Functions

func CreateTiStore

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

CreateTiStore creates a new tikv storage client

func GetSafeResolvedTs

func GetSafeResolvedTs(resolvedTs uint64) uint64

func InitMetrics

func InitMetrics(registry *prometheus.Registry)

InitMetrics registers all metrics in the kv package

func InitWorkerPool

func InitWorkerPool()

InitWorkerPool initialize workerpool once, the workerpool must be initialized before any kv event is received.

func NewSizedRegionRouter

func NewSizedRegionRouter(ctx context.Context, sizeLimit int) *sizedRegionRouter

NewSizedRegionRouter creates a new sizedRegionRouter

func RunWorkerPool

func RunWorkerPool(ctx context.Context) error

RunWorkerPool runs the worker pool used by the region worker in kv client v2 It must be running before region worker starts to work

Types

type CDCClient

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

CDCClient to get events from TiKV

func (*CDCClient) EventFeed

func (c *CDCClient) EventFeed(
	ctx context.Context, span regionspan.ComparableSpan, ts uint64,
	enableOldValue bool,
	lockResolver txnutil.LockResolver,
	isPullerInit PullerInitialization,
	eventCh chan<- model.RegionFeedEvent,
) error

EventFeed divides a EventFeed request on range boundaries and establishes a EventFeed to each of the individual region. It streams back result on the provided channel. The `Start` and `End` field in input span must be memcomparable encoded.

type CDCKVClient

type CDCKVClient interface {
	EventFeed(
		ctx context.Context,
		span regionspan.ComparableSpan,
		ts uint64,
		enableOldValue bool,
		lockResolver txnutil.LockResolver,
		isPullerInit PullerInitialization,
		eventCh chan<- model.RegionFeedEvent,
	) error
}

CDCKVClient is an interface to receives kv changed logs from TiKV

func NewCDCClient

func NewCDCClient(ctx context.Context, pd pd.Client, kvStorage tikv.Storage, grpcPool GrpcPool, regionCache *tikv.RegionCache) (c CDCKVClient)

NewCDCClient creates a CDCClient instance

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)

	// Recycle 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 LimitRegionRouter

type LimitRegionRouter interface {
	// Chan returns a singleRegionInfo channel that can be consumed from
	Chan() <-chan singleRegionInfo
	// AddRegion adds an singleRegionInfo to buffer, this function is thread-safe
	AddRegion(task singleRegionInfo)
	// Acquire acquires one token
	Acquire(id string)
	// Release gives back one token, this function is thread-safe
	Release(id string)
	// Run runs in background and does some logic work
	Run(ctx context.Context) error
}

LimitRegionRouter defines an interface that can buffer singleRegionInfo and provide token based consumption

type PullerInitialization

type PullerInitialization interface {
	IsInitialized() bool
}

PullerInitialization is a workaround to solved cyclic import.

type StorageWithCurVersionCache

type StorageWithCurVersionCache struct {
	tikv.Storage
	// contains filtered or unexported fields
}

StorageWithCurVersionCache adds GetCachedCurrentVersion() to tikv.Storage

func (*StorageWithCurVersionCache) GetCachedCurrentVersion

func (s *StorageWithCurVersionCache) GetCachedCurrentVersion() (version uint64, err error)

GetCachedCurrentVersion gets the cached version of currentVersion, and update the cache if necessary

type TiKVStorage

type TiKVStorage interface {
	tikv.Storage
	GetCachedCurrentVersion() (version uint64, err error)
}

TiKVStorage is the tikv storage interface used by CDC.

Jump to

Keyboard shortcuts

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