mockstore

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2023 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DDLCheckerInjector func(kv.Storage) kv.Storage

DDLCheckerInjector is used to break import cycle.

Functions

func BootstrapWithMultiRegions

func BootstrapWithMultiRegions(cluster testutils.Cluster, splitKeys ...[]byte) (storeID uint64, regionIDs, peerIDs []uint64)

BootstrapWithMultiRegions initializes a Cluster with multiple Regions and 1 Store. The number of Regions will be len(splitKeys) + 1.

func BootstrapWithMultiStores

func BootstrapWithMultiStores(cluster testutils.Cluster, n int) (storeIDs, peerIDs []uint64, regionID uint64, leaderPeer uint64)

BootstrapWithMultiStores initializes a Cluster with 1 Region and n Stores.

func BootstrapWithSingleStore

func BootstrapWithSingleStore(cluster testutils.Cluster) (storeID, peerID, regionID uint64)

BootstrapWithSingleStore initializes a Cluster with 1 Region and 1 Store.

func NewMockStore

func NewMockStore(options ...MockTiKVStoreOption) (kv.Storage, error)

NewMockStore creates a mocked tikv store, the path is the file path to store the data. If path is an empty string, a memory storage will be created.

Types

type EmbedUnistoreDriver

type EmbedUnistoreDriver struct{}

EmbedUnistoreDriver is in embedded unistore driver.

func (EmbedUnistoreDriver) Open

func (d EmbedUnistoreDriver) Open(path string) (kv.Storage, error)

Open creates a EmbedUnistore storage.

type MockTiKVDriver

type MockTiKVDriver struct{}

MockTiKVDriver is in memory mock TiKV driver.

func (MockTiKVDriver) Open

func (d MockTiKVDriver) Open(path string) (kv.Storage, error)

Open creates a MockTiKV storage.

type MockTiKVStoreOption

type MockTiKVStoreOption func(*mockOptions)

MockTiKVStoreOption is used to control some behavior of mock tikv.

func WithClientHijacker

func WithClientHijacker(hijacker func(tikv.Client) tikv.Client) MockTiKVStoreOption

WithClientHijacker hijacks KV client's behavior, makes it easy to simulate the network problem between TiDB and TiKV.

func WithClusterInspector

func WithClusterInspector(inspector func(testutils.Cluster)) MockTiKVStoreOption

WithClusterInspector lets user to inspect the mock cluster handler.

func WithDDLChecker

func WithDDLChecker() MockTiKVStoreOption

WithDDLChecker prepare injected DDL implementation for the domain of this store. It must be done before bootstrap to avoid data race with dom.ddl.

func WithMultipleOptions

func WithMultipleOptions(opts ...MockTiKVStoreOption) MockTiKVStoreOption

WithMultipleOptions merges multiple options into one option.

func WithPDClientHijacker

func WithPDClientHijacker(hijacker func(pd.Client) pd.Client) MockTiKVStoreOption

WithPDClientHijacker hijacks PD client's behavior, makes it easy to simulate the network problem between TiDB and PD.

func WithPath

func WithPath(path string) MockTiKVStoreOption

WithPath specifies the mocktikv path.

func WithStoreType

func WithStoreType(tp StoreType) MockTiKVStoreOption

WithStoreType lets user choose the backend storage's type.

func WithTxnLocalLatches

func WithTxnLocalLatches(capacity uint) MockTiKVStoreOption

WithTxnLocalLatches enable txnLocalLatches, when capacity > 0.

type StoreType

type StoreType uint8

StoreType is the type of backend mock storage.

const (
	// MockTiKV is the mock storage based on goleveldb.
	MockTiKV StoreType = iota
	// EmbedUnistore is the mock storage based on unistore.
	EmbedUnistore
)

Jump to

Keyboard shortcuts

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