-
Notifications
You must be signed in to change notification settings - Fork 231
/
Copy pathmockstore.go
61 lines (47 loc) · 2.22 KB
/
mockstore.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// Copyright 2021 TiKV Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package testutils
import (
"github.com/tikv/client-go/v2/internal/mockstore/cluster"
"github.com/tikv/client-go/v2/internal/mockstore/mocktikv"
pd "github.com/tikv/pd/client"
)
// Cluster simulates a TiKV cluster.
type Cluster = cluster.Cluster
// CoprRPCHandler is the interface to handle coprocessor RPC commands.
type CoprRPCHandler = mocktikv.CoprRPCHandler
// MVCCStore is a mvcc key-value storage.
type MVCCStore = mocktikv.MVCCStore
// MVCCPair is a KV pair read from MvccStore or an error if any occurs.
type MVCCPair = mocktikv.Pair
// MockCluster simulates a TiKV cluster.
type MockCluster = mocktikv.Cluster
// MockClient sends kv RPC calls to mock cluster.
type MockClient = mocktikv.RPCClient
// RPCSession stores session scope rpc data.
type RPCSession = mocktikv.Session
// NewMockTiKV creates a TiKV client and PD client from options.
func NewMockTiKV(path string, coprHandler CoprRPCHandler) (*MockClient, *MockCluster, pd.Client, error) {
return mocktikv.NewTiKVAndPDClient(path, coprHandler)
}
// BootstrapWithSingleStore initializes a Cluster with 1 Region and 1 Store.
var BootstrapWithSingleStore = mocktikv.BootstrapWithSingleStore
// BootstrapWithMultiStores initializes a Cluster with 1 Region and n Stores.
var BootstrapWithMultiStores = mocktikv.BootstrapWithMultiStores
// BootstrapWithMultiRegions initializes a Cluster with multiple Regions and 1
// Store. The number of Regions will be len(splitKeys) + 1.
var BootstrapWithMultiRegions = mocktikv.BootstrapWithMultiRegions
// ErrLocked is returned when trying to Read/Write on a locked key. Client should
// backoff or cleanup the lock then retry.
type ErrLocked = mocktikv.ErrLocked