kv

package
v0.0.0-...-44a46bf Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2024 License: Apache-2.0 Imports: 40 Imported by: 6

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.Reader

GetSnapshotMeta returns tidb meta information

func InitMetrics

func InitMetrics(registry *prometheus.Registry)

InitMetrics registers all metrics in the kv package

Types

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