tikvrpc

package
v0.0.0-...-67646e2 Latest Latest
Warning

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

Go to latest
Published: May 8, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckStreamTimeoutLoop

func CheckStreamTimeoutLoop(ch <-chan *Lease, done <-chan struct{})

CheckStreamTimeoutLoop runs periodically to check is there any stream request timeouted. Lease is an object to track stream requests, call this function with "go CheckStreamTimeoutLoop()" It is not guaranteed to call every Lease.Cancel() putting into channel when exits. If grpc-go supports SetDeadline(https://github.com/grpc/grpc-go/issues/2917), we can stop using this method.

func SetContext

func SetContext(req *Request, region *metapb.Region, peer *metapb.Peer) error

SetContext set the Context field for the given req to the specified ctx.

Types

type CmdType

type CmdType uint16

CmdType represents the concrete request type in Request or response type in Response.

const (
	CmdGet CmdType = 1 + iota
	CmdScan
	CmdPrewrite
	CmdCommit
	CmdCleanup
	CmdBatchGet
	CmdBatchRollback
	CmdScanLock
	CmdResolveLock
	CmdGC
	CmdDeleteRange
	CmdPessimisticLock
	CmdPessimisticRollback
	CmdTxnHeartBeat
	CmdCheckTxnStatus

	CmdRawGet CmdType = 256 + iota
	CmdRawBatchGet
	CmdRawPut
	CmdRawBatchPut
	CmdRawDelete
	CmdRawBatchDelete
	CmdRawDeleteRange
	CmdRawScan

	CmdUnsafeDestroyRange

	CmdRegisterLockObserver
	CmdCheckLockObserver
	CmdRemoveLockObserver
	CmdPhysicalScanLock

	CmdCop CmdType = 512 + iota
	CmdCopStream

	CmdMvccGetByKey CmdType = 1024 + iota
	CmdMvccGetByStartTs
	CmdSplitRegion

	CmdDebugGetRegionProperties CmdType = 2048 + iota

	CmdEmpty CmdType = 3072 + iota
)

CmdType values.

func (CmdType) String

func (t CmdType) String() string

type CopStreamResponse

type CopStreamResponse struct {
	tikvpb.Tikv_CoprocessorStreamClient
	*coprocessor.Response // The first result of Recv()
	Timeout               time.Duration
	Lease                 // Shared by this object and a background goroutine.
}

CopStreamResponse combinates tikvpb.Tikv_CoprocessorStreamClient and the first Recv() result together. In streaming API, get grpc stream client may not involve any network packet, then region error have to be handled in Recv() function. This struct facilitates the error handling.

func (*CopStreamResponse) Close

func (resp *CopStreamResponse) Close()

Close closes the CopStreamResponse object.

func (*CopStreamResponse) Recv

func (resp *CopStreamResponse) Recv() (*coprocessor.Response, error)

Recv overrides the stream client Recv() function.

type Lease

type Lease struct {
	Cancel context.CancelFunc
	// contains filtered or unexported fields
}

Lease is used to implement grpc stream timeout.

type Request

type Request struct {
	Type CmdType

	kvrpcpb.Context
	ReplicaReadSeed uint32
	StoreTp         kv.StoreType
	// contains filtered or unexported fields
}

Request wraps all kv/coprocessor requests.

func NewReplicaReadRequest

func NewReplicaReadRequest(typ CmdType, pointer interface{}, replicaReadType kv.ReplicaReadType, replicaReadSeed uint32, ctxs ...kvrpcpb.Context) *Request

NewReplicaReadRequest returns new kv rpc request with replica read.

func NewRequest

func NewRequest(typ CmdType, pointer interface{}, ctxs ...kvrpcpb.Context) *Request

NewRequest returns new kv rpc request.

func (*Request) BatchGet

func (req *Request) BatchGet() *kvrpcpb.BatchGetRequest

BatchGet returns BatchGetRequest in request.

func (*Request) BatchRollback

func (req *Request) BatchRollback() *kvrpcpb.BatchRollbackRequest

BatchRollback returns BatchRollbackRequest in request.

func (*Request) CheckLockObserver

func (req *Request) CheckLockObserver() *kvrpcpb.CheckLockObserverRequest

CheckLockObserver returns CheckLockObserverRequest in request.

func (*Request) CheckTxnStatus

func (req *Request) CheckTxnStatus() *kvrpcpb.CheckTxnStatusRequest

CheckTxnStatus returns CheckTxnStatusRequest in request.

func (*Request) Cleanup

func (req *Request) Cleanup() *kvrpcpb.CleanupRequest

Cleanup returns CleanupRequest in request.

func (*Request) Commit

func (req *Request) Commit() *kvrpcpb.CommitRequest

Commit returns CommitRequest in request.

func (*Request) Cop

func (req *Request) Cop() *coprocessor.Request

Cop returns coprocessor request in request.

func (*Request) DebugGetRegionProperties

func (req *Request) DebugGetRegionProperties() *debugpb.GetRegionPropertiesRequest

DebugGetRegionProperties returns GetRegionPropertiesRequest in request.

func (*Request) DeleteRange

func (req *Request) DeleteRange() *kvrpcpb.DeleteRangeRequest

DeleteRange returns DeleteRangeRequest in request.

func (*Request) Empty

Empty returns BatchCommandsEmptyRequest in request.

func (*Request) GC

func (req *Request) GC() *kvrpcpb.GCRequest

GC returns GCRequest in request.

func (*Request) Get

func (req *Request) Get() *kvrpcpb.GetRequest

Get returns GetRequest in request.

func (*Request) IsDebugReq

func (req *Request) IsDebugReq() bool

IsDebugReq check whether the req is debug req.

func (*Request) MvccGetByKey

func (req *Request) MvccGetByKey() *kvrpcpb.MvccGetByKeyRequest

MvccGetByKey returns MvccGetByKeyRequest in request.

func (*Request) MvccGetByStartTs

func (req *Request) MvccGetByStartTs() *kvrpcpb.MvccGetByStartTsRequest

MvccGetByStartTs returns MvccGetByStartTsRequest in request.

func (*Request) PessimisticLock

func (req *Request) PessimisticLock() *kvrpcpb.PessimisticLockRequest

PessimisticLock returns PessimisticLockRequest in request.

func (*Request) PessimisticRollback

func (req *Request) PessimisticRollback() *kvrpcpb.PessimisticRollbackRequest

PessimisticRollback returns PessimisticRollbackRequest in request.

func (*Request) PhysicalScanLock

func (req *Request) PhysicalScanLock() *kvrpcpb.PhysicalScanLockRequest

PhysicalScanLock returns PhysicalScanLockRequest in request.

func (*Request) Prewrite

func (req *Request) Prewrite() *kvrpcpb.PrewriteRequest

Prewrite returns PrewriteRequest in request.

func (*Request) RawBatchDelete

func (req *Request) RawBatchDelete() *kvrpcpb.RawBatchDeleteRequest

RawBatchDelete returns RawBatchDeleteRequest in request.

func (*Request) RawBatchGet

func (req *Request) RawBatchGet() *kvrpcpb.RawBatchGetRequest

RawBatchGet returns RawBatchGetRequest in request.

func (*Request) RawBatchPut

func (req *Request) RawBatchPut() *kvrpcpb.RawBatchPutRequest

RawBatchPut returns RawBatchPutRequest in request.

func (*Request) RawDelete

func (req *Request) RawDelete() *kvrpcpb.RawDeleteRequest

RawDelete returns PrewriteRequest in request.

func (*Request) RawDeleteRange

func (req *Request) RawDeleteRange() *kvrpcpb.RawDeleteRangeRequest

RawDeleteRange returns RawDeleteRangeRequest in request.

func (*Request) RawGet

func (req *Request) RawGet() *kvrpcpb.RawGetRequest

RawGet returns RawGetRequest in request.

func (*Request) RawPut

func (req *Request) RawPut() *kvrpcpb.RawPutRequest

RawPut returns RawPutRequest in request.

func (*Request) RawScan

func (req *Request) RawScan() *kvrpcpb.RawScanRequest

RawScan returns RawScanRequest in request.

func (*Request) RegisterLockObserver

func (req *Request) RegisterLockObserver() *kvrpcpb.RegisterLockObserverRequest

RegisterLockObserver returns RegisterLockObserverRequest in request.

func (*Request) RemoveLockObserver

func (req *Request) RemoveLockObserver() *kvrpcpb.RemoveLockObserverRequest

RemoveLockObserver returns RemoveLockObserverRequest in request.

func (*Request) ResolveLock

func (req *Request) ResolveLock() *kvrpcpb.ResolveLockRequest

ResolveLock returns ResolveLockRequest in request.

func (*Request) Scan

func (req *Request) Scan() *kvrpcpb.ScanRequest

Scan returns ScanRequest in request.

func (*Request) ScanLock

func (req *Request) ScanLock() *kvrpcpb.ScanLockRequest

ScanLock returns ScanLockRequest in request.

func (*Request) SplitRegion

func (req *Request) SplitRegion() *kvrpcpb.SplitRegionRequest

SplitRegion returns SplitRegionRequest in request.

func (*Request) ToBatchCommandsRequest

func (req *Request) ToBatchCommandsRequest() *tikvpb.BatchCommandsRequest_Request

ToBatchCommandsRequest converts the request to an entry in BatchCommands request.

func (*Request) TxnHeartBeat

func (req *Request) TxnHeartBeat() *kvrpcpb.TxnHeartBeatRequest

TxnHeartBeat returns TxnHeartBeatRequest in request.

func (*Request) UnsafeDestroyRange

func (req *Request) UnsafeDestroyRange() *kvrpcpb.UnsafeDestroyRangeRequest

UnsafeDestroyRange returns UnsafeDestroyRangeRequest in request.

type Response

type Response struct {
	Resp interface{}
}

Response wraps all kv/coprocessor responses.

func CallDebugRPC

func CallDebugRPC(ctx context.Context, client debugpb.DebugClient, req *Request) (*Response, error)

CallDebugRPC launches a debug rpc call.

func CallRPC

func CallRPC(ctx context.Context, client tikvpb.TikvClient, req *Request) (*Response, error)

CallRPC launches a rpc call. ch is needed to implement timeout for coprocessor streaing, the stream object's cancel function will be sent to the channel, together with a lease checked by a background goroutine.

func FromBatchCommandsResponse

func FromBatchCommandsResponse(res *tikvpb.BatchCommandsResponse_Response) (*Response, error)

FromBatchCommandsResponse converts a BatchCommands response to Response.

func GenRegionErrorResp

func GenRegionErrorResp(req *Request, e *errorpb.Error) (*Response, error)

GenRegionErrorResp returns corresponding Response with specified RegionError according to the given req.

func (*Response) GetRegionError

func (resp *Response) GetRegionError() (*errorpb.Error, error)

GetRegionError returns the RegionError of the underlying concrete response.

Jump to

Keyboard shortcuts

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