From 99c0abada39ee30d75b948920830b00d655ecd20 Mon Sep 17 00:00:00 2001 From: Shirly Date: Tue, 23 Feb 2021 09:58:45 +0800 Subject: [PATCH] tikv/interface:remove kv.Storage from tikv.Storage (#22868) --- go.mod | 2 +- go.sum | 4 ++-- store/tikv/interface.go | 37 +++++++++++++++++++++++++++++++++++-- 3 files changed, 38 insertions(+), 5 deletions(-) diff --git a/go.mod b/go.mod index 8915fed1bd24e..b45de396de353 100644 --- a/go.mod +++ b/go.mod @@ -38,7 +38,7 @@ require ( github.com/phayes/freeport v0.0.0-20180830031419-95f893ade6f2 github.com/pierrec/lz4 v2.5.2+incompatible // indirect github.com/pingcap/badger v1.5.1-0.20200908111422-2e78ee155d19 - github.com/pingcap/br v4.0.0-beta.2.0.20210115100158-7a7b4a421c0a+incompatible + github.com/pingcap/br v4.0.0-beta.2.0.20210220133344-578be7fb5165+incompatible github.com/pingcap/check v0.0.0-20200212061837-5e12011dc712 github.com/pingcap/errors v0.11.5-0.20201126102027-b0a155152ca3 github.com/pingcap/failpoint v0.0.0-20200702092429-9f69995143ce diff --git a/go.sum b/go.sum index d363a0a12c1c7..e49a256ab00b7 100644 --- a/go.sum +++ b/go.sum @@ -381,8 +381,8 @@ github.com/pierrec/lz4 v2.5.2+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi github.com/pingcap-incubator/tidb-dashboard v0.0.0-20210104140916-41a0a3a87e75/go.mod h1:EONGys2gM5n14pII2vjmU/5VG3Dtj6kpqUT1GUZ4ysw= github.com/pingcap/badger v1.5.1-0.20200908111422-2e78ee155d19 h1:IXpGy7y9HyoShAFmzW2OPF0xCA5EOoSTyZHwsgYk9Ro= github.com/pingcap/badger v1.5.1-0.20200908111422-2e78ee155d19/go.mod h1:LyrqUOHZrUDf9oGi1yoz1+qw9ckSIhQb5eMa1acOLNQ= -github.com/pingcap/br v4.0.0-beta.2.0.20210115100158-7a7b4a421c0a+incompatible h1:idKUWy8no4l5bhnVAhLm4PeiASI411O2XADzpuJmicg= -github.com/pingcap/br v4.0.0-beta.2.0.20210115100158-7a7b4a421c0a+incompatible/go.mod h1:ymVmo50lQydxib0tmK5hHk4oteB7hZ0IMCArunwy3UQ= +github.com/pingcap/br v4.0.0-beta.2.0.20210220133344-578be7fb5165+incompatible h1:Zd4LjoIYVmGF9KW484B0F+XvFHlcp9hraI5FAB9h1/I= +github.com/pingcap/br v4.0.0-beta.2.0.20210220133344-578be7fb5165+incompatible/go.mod h1:ymVmo50lQydxib0tmK5hHk4oteB7hZ0IMCArunwy3UQ= github.com/pingcap/check v0.0.0-20190102082844-67f458068fc8/go.mod h1:B1+S9LNcuMyLH/4HMTViQOJevkGiik3wW2AN9zb2fNQ= github.com/pingcap/check v0.0.0-20191107115940-caf2b9e6ccf4/go.mod h1:PYMCGwN0JHjoqGr3HrZoD+b8Tgx8bKnArhSq8YVzUMc= github.com/pingcap/check v0.0.0-20191216031241-8a5a85928f12/go.mod h1:PYMCGwN0JHjoqGr3HrZoD+b8Tgx8bKnArhSq8YVzUMc= diff --git a/store/tikv/interface.go b/store/tikv/interface.go index 0cff79c13b800..2848c006c4476 100644 --- a/store/tikv/interface.go +++ b/store/tikv/interface.go @@ -14,6 +14,7 @@ package tikv import ( + "context" "time" "github.com/pingcap/tidb/kv" @@ -23,8 +24,6 @@ import ( // Storage represent the kv.Storage runs on TiKV. type Storage interface { - kv.Storage - // GetRegionCache gets the RegionCache. GetRegionCache() *RegionCache @@ -51,4 +50,38 @@ type Storage interface { // Closed returns the closed channel. Closed() <-chan struct{} + + // Begin a global transaction + Begin() (kv.Transaction, error) + // Begin a transaction with the given txnScope (local or global) + BeginWithTxnScope(txnScope string) (kv.Transaction, error) + // BeginWithStartTS begins transaction with given txnScope and startTS. + BeginWithStartTS(txnScope string, startTS uint64) (kv.Transaction, error) + // BeginWithStalenessTS begins transaction with given staleness + BeginWithExactStaleness(txnScope string, prevSec uint64) (kv.Transaction, error) + // GetSnapshot gets a snapshot that is able to read any data which data is <= ver. + // if ver is MaxVersion or > current max committed version, we will use current version for this snapshot. + GetSnapshot(ver kv.Version) kv.Snapshot + // GetClient gets a client instance. + GetClient() kv.Client + // GetMPPClient gets a mpp client instance. + GetMPPClient() kv.MPPClient + // Close store + Close() error + // UUID return a unique ID which represents a Storage. + UUID() string + // CurrentVersion returns current max committed version with the given txnScope (local or global). + CurrentVersion(txnScope string) (kv.Version, error) + // GetOracle gets a timestamp oracle client. + GetOracle() oracle.Oracle + // SupportDeleteRange gets the storage support delete range or not. + SupportDeleteRange() (supported bool) + // Name gets the name of the storage engine + Name() string + // Describe returns of brief introduction of the storage + Describe() string + // ShowStatus returns the specified status of the storage + ShowStatus(ctx context.Context, key string) (interface{}, error) + // GetMemCache return memory manager of the storage + GetMemCache() kv.MemManager }