Documentation ¶
Index ¶
- Variables
- func BootstrapWithMultiRegions(cluster *Cluster, splitKeys ...[]byte) (storeID uint64, regionIDs, peerIDs []uint64)
- func BootstrapWithMultiStores(cluster *Cluster, n int) (storeIDs, peerIDs []uint64, regionID uint64, leaderPeer uint64)
- func BootstrapWithSingleStore(cluster *Cluster) (storeID, peerID, regionID uint64)
- func New(path string, pdAddrs []string) (*RPCClient, pd.Client, *Cluster, error)
- func NewMockPDServiceDiscovery(addrs []string) sd.ServiceDiscovery
- type Cluster
- type RPCClient
Constants ¶
This section is empty.
Variables ¶
var CheckResourceTagForTopSQLInGoTest bool
CheckResourceTagForTopSQLInGoTest is used to identify whether check resource tag for TopSQL.
var UnistoreRPCClientSendHook atomic.Pointer[func(*tikvrpc.Request)]
UnistoreRPCClientSendHook exports for test.
Functions ¶
func BootstrapWithMultiRegions ¶
func BootstrapWithMultiRegions(cluster *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 *Cluster, n int) (storeIDs, peerIDs []uint64, regionID uint64, leaderPeer uint64)
BootstrapWithMultiStores initializes a Cluster with 1 Region and n Stores.
func BootstrapWithSingleStore ¶
BootstrapWithSingleStore initializes a Cluster with 1 Region and 1 Store.
func NewMockPDServiceDiscovery ¶
func NewMockPDServiceDiscovery(addrs []string) sd.ServiceDiscovery
NewMockPDServiceDiscovery returns a mock PD ServiceDiscovery
Types ¶
type Cluster ¶
type Cluster struct { *us.MockRegionManager // contains filtered or unexported fields }
Cluster simulates a TiKV cluster. It focuses on management and the change of meta data. A Cluster mainly includes following 3 kinds of meta data:
- Region: A Region is a fragment of TiKV's data whose range is [start, end). The data of a Region is duplicated to multiple Peers and distributed in multiple Stores.
- Peer: A Peer is a replica of a Region's data. All peers of a Region form a group, each group elects a Leader to provide services.
- Store: A Store is a storage/service node. Try to think it as a TiKV server process. Only the store with request's Region's leader Peer could respond to client's request.
func (*Cluster) ScheduleDelay ¶
ScheduleDelay schedules a delay event for a transaction on a region.
type RPCClient ¶
type RPCClient struct {
// contains filtered or unexported fields
}
RPCClient sends kv RPC calls to mock cluster. RPCClient mocks the behavior of a rpc client at tikv's side.
func (*RPCClient) SendRequest ¶
func (c *RPCClient) SendRequest(ctx context.Context, addr string, req *tikvrpc.Request, timeout time.Duration) (*tikvrpc.Response, error)
SendRequest sends a request to mock cluster.
func (*RPCClient) SetEventListener ¶
func (c *RPCClient) SetEventListener(listener tikv.ClientEventListener)
SetEventListener implements tikv.Client interface.