github.com/KinWaiYuen/client-go/v2@v2.5.4/tikv/interface.go (about)

     1  // Copyright 2021 TiKV Authors
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  // NOTE: The code in this file is based on code from the
    16  // TiDB project, licensed under the Apache License v 2.0
    17  //
    18  // https://github.com/pingcap/tidb/tree/cc5e161ac06827589c4966674597c137cc9e809c/store/tikv/interface.go
    19  //
    20  
    21  // Copyright 2017 PingCAP, Inc.
    22  //
    23  // Licensed under the Apache License, Version 2.0 (the "License");
    24  // you may not use this file except in compliance with the License.
    25  // You may obtain a copy of the License at
    26  //
    27  //     http://www.apache.org/licenses/LICENSE-2.0
    28  //
    29  // Unless required by applicable law or agreed to in writing, software
    30  // distributed under the License is distributed on an "AS IS" BASIS,
    31  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    32  // See the License for the specific language governing permissions and
    33  // limitations under the License.
    34  
    35  package tikv
    36  
    37  import (
    38  	"time"
    39  
    40  	"github.com/KinWaiYuen/client-go/v2/internal/locate"
    41  	"github.com/KinWaiYuen/client-go/v2/oracle"
    42  	"github.com/KinWaiYuen/client-go/v2/tikvrpc"
    43  	"github.com/KinWaiYuen/client-go/v2/txnkv/txnlock"
    44  )
    45  
    46  // Storage represent the kv.Storage runs on TiKV.
    47  type Storage interface {
    48  	// GetRegionCache gets the RegionCache.
    49  	GetRegionCache() *locate.RegionCache
    50  
    51  	// SendReq sends a request to TiKV.
    52  	SendReq(bo *Backoffer, req *tikvrpc.Request, regionID locate.RegionVerID, timeout time.Duration) (*tikvrpc.Response, error)
    53  
    54  	// GetLockResolver gets the LockResolver.
    55  	GetLockResolver() *txnlock.LockResolver
    56  
    57  	// GetSafePointKV gets the SafePointKV.
    58  	GetSafePointKV() SafePointKV
    59  
    60  	// UpdateSPCache updates the cache of safe point.
    61  	UpdateSPCache(cachedSP uint64, cachedTime time.Time)
    62  
    63  	// SetOracle sets the Oracle.
    64  	SetOracle(oracle oracle.Oracle)
    65  
    66  	// SetTiKVClient sets the TiKV client.
    67  	SetTiKVClient(client Client)
    68  
    69  	// GetTiKVClient gets the TiKV client.
    70  	GetTiKVClient() Client
    71  
    72  	// Closed returns the closed channel.
    73  	Closed() <-chan struct{}
    74  
    75  	// Close store
    76  	Close() error
    77  	// UUID return a unique ID which represents a Storage.
    78  	UUID() string
    79  	// CurrentTimestamp returns current timestamp with the given txnScope (local or global).
    80  	CurrentTimestamp(txnScope string) (uint64, error)
    81  	// GetOracle gets a timestamp oracle client.
    82  	GetOracle() oracle.Oracle
    83  	// SupportDeleteRange gets the storage support delete range or not.
    84  	SupportDeleteRange() (supported bool)
    85  }