Documentation ¶
Index ¶
- func CheckStreamTimeoutLoop(ch <-chan *Lease, done <-chan struct{})
- func SetContext(req *Request, region *metapb.Region, peer *metapb.Peer) error
- type CmdType
- type CopStreamResponse
- type Lease
- type Request
- func (req *Request) BatchGet() *kvrpcpb.BatchGetRequest
- func (req *Request) BatchRollback() *kvrpcpb.BatchRollbackRequest
- func (req *Request) CheckLockObserver() *kvrpcpb.CheckLockObserverRequest
- func (req *Request) CheckTxnStatus() *kvrpcpb.CheckTxnStatusRequest
- func (req *Request) Cleanup() *kvrpcpb.CleanupRequest
- func (req *Request) Commit() *kvrpcpb.CommitRequest
- func (req *Request) Cop() *coprocessor.Request
- func (req *Request) DebugGetRegionProperties() *debugpb.GetRegionPropertiesRequest
- func (req *Request) DeleteRange() *kvrpcpb.DeleteRangeRequest
- func (req *Request) Empty() *tikvpb.BatchCommandsEmptyRequest
- func (req *Request) GC() *kvrpcpb.GCRequest
- func (req *Request) Get() *kvrpcpb.GetRequest
- func (req *Request) IsDebugReq() bool
- func (req *Request) MvccGetByKey() *kvrpcpb.MvccGetByKeyRequest
- func (req *Request) MvccGetByStartTs() *kvrpcpb.MvccGetByStartTsRequest
- func (req *Request) PessimisticLock() *kvrpcpb.PessimisticLockRequest
- func (req *Request) PessimisticRollback() *kvrpcpb.PessimisticRollbackRequest
- func (req *Request) PhysicalScanLock() *kvrpcpb.PhysicalScanLockRequest
- func (req *Request) Prewrite() *kvrpcpb.PrewriteRequest
- func (req *Request) RawBatchDelete() *kvrpcpb.RawBatchDeleteRequest
- func (req *Request) RawBatchGet() *kvrpcpb.RawBatchGetRequest
- func (req *Request) RawBatchPut() *kvrpcpb.RawBatchPutRequest
- func (req *Request) RawDelete() *kvrpcpb.RawDeleteRequest
- func (req *Request) RawDeleteRange() *kvrpcpb.RawDeleteRangeRequest
- func (req *Request) RawGet() *kvrpcpb.RawGetRequest
- func (req *Request) RawPut() *kvrpcpb.RawPutRequest
- func (req *Request) RawScan() *kvrpcpb.RawScanRequest
- func (req *Request) RegisterLockObserver() *kvrpcpb.RegisterLockObserverRequest
- func (req *Request) RemoveLockObserver() *kvrpcpb.RemoveLockObserverRequest
- func (req *Request) ResolveLock() *kvrpcpb.ResolveLockRequest
- func (req *Request) Scan() *kvrpcpb.ScanRequest
- func (req *Request) ScanLock() *kvrpcpb.ScanLockRequest
- func (req *Request) SplitRegion() *kvrpcpb.SplitRegionRequest
- func (req *Request) ToBatchCommandsRequest() *tikvpb.BatchCommandsRequest_Request
- func (req *Request) TxnHeartBeat() *kvrpcpb.TxnHeartBeatRequest
- func (req *Request) UnsafeDestroyRange() *kvrpcpb.UnsafeDestroyRangeRequest
- type Response
- func CallDebugRPC(ctx context.Context, client debugpb.DebugClient, req *Request) (*Response, error)
- func CallRPC(ctx context.Context, client tikvpb.TikvClient, req *Request) (*Response, error)
- func FromBatchCommandsResponse(res *tikvpb.BatchCommandsResponse_Response) (*Response, error)
- func GenRegionErrorResp(req *Request, e *errorpb.Error) (*Response, error)
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.
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.
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 ¶
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 ¶
func (req *Request) Empty() *tikvpb.BatchCommandsEmptyRequest
Empty returns BatchCommandsEmptyRequest in request.
func (*Request) Get ¶
func (req *Request) Get() *kvrpcpb.GetRequest
Get returns GetRequest in request.
func (*Request) IsDebugReq ¶
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 ¶
CallDebugRPC launches a debug rpc call.
func CallRPC ¶
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 ¶
GenRegionErrorResp returns corresponding Response with specified RegionError according to the given req.