Documentation ¶
Index ¶
- func CheckStreamTimeoutLoop(ch <-chan *Lease)
- func SetContext(req *Request, region *metapb.Region, peer *metapb.Peer) error
- type CmdType
- type CopStreamResponse
- type Lease
- type Request
- 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
- 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)
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()"
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 CmdRawGet CmdType = 256 + iota CmdRawBatchGet CmdRawPut CmdRawBatchPut CmdRawDelete CmdRawBatchDelete CmdRawDeleteRange CmdRawScan CmdUnsafeDestroyRange 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 { kvrpcpb.Context Type CmdType Get *kvrpcpb.GetRequest Scan *kvrpcpb.ScanRequest Prewrite *kvrpcpb.PrewriteRequest Commit *kvrpcpb.CommitRequest Cleanup *kvrpcpb.CleanupRequest BatchGet *kvrpcpb.BatchGetRequest BatchRollback *kvrpcpb.BatchRollbackRequest ScanLock *kvrpcpb.ScanLockRequest ResolveLock *kvrpcpb.ResolveLockRequest GC *kvrpcpb.GCRequest DeleteRange *kvrpcpb.DeleteRangeRequest RawGet *kvrpcpb.RawGetRequest RawBatchGet *kvrpcpb.RawBatchGetRequest RawPut *kvrpcpb.RawPutRequest RawBatchPut *kvrpcpb.RawBatchPutRequest RawDelete *kvrpcpb.RawDeleteRequest RawBatchDelete *kvrpcpb.RawBatchDeleteRequest RawDeleteRange *kvrpcpb.RawDeleteRangeRequest RawScan *kvrpcpb.RawScanRequest UnsafeDestroyRange *kvrpcpb.UnsafeDestroyRangeRequest Cop *coprocessor.Request MvccGetByKey *kvrpcpb.MvccGetByKeyRequest MvccGetByStartTs *kvrpcpb.MvccGetByStartTsRequest SplitRegion *kvrpcpb.SplitRegionRequest PessimisticLock *kvrpcpb.PessimisticLockRequest PessimisticRollback *kvrpcpb.PessimisticRollbackRequest DebugGetRegionProperties *debugpb.GetRegionPropertiesRequest Empty *tikvpb.BatchCommandsEmptyRequest }
Request wraps all kv/coprocessor requests.
func (*Request) IsDebugReq ¶
IsDebugReq check whether the req is debug req.
func (*Request) ToBatchCommandsRequest ¶
func (req *Request) ToBatchCommandsRequest() *tikvpb.BatchCommandsRequest_Request
ToBatchCommandsRequest converts the request to an entry in BatchCommands request.
type Response ¶
type Response struct { Type CmdType Get *kvrpcpb.GetResponse Scan *kvrpcpb.ScanResponse Prewrite *kvrpcpb.PrewriteResponse Commit *kvrpcpb.CommitResponse Cleanup *kvrpcpb.CleanupResponse BatchGet *kvrpcpb.BatchGetResponse BatchRollback *kvrpcpb.BatchRollbackResponse ScanLock *kvrpcpb.ScanLockResponse ResolveLock *kvrpcpb.ResolveLockResponse GC *kvrpcpb.GCResponse DeleteRange *kvrpcpb.DeleteRangeResponse RawGet *kvrpcpb.RawGetResponse RawBatchGet *kvrpcpb.RawBatchGetResponse RawPut *kvrpcpb.RawPutResponse RawBatchPut *kvrpcpb.RawBatchPutResponse RawDelete *kvrpcpb.RawDeleteResponse RawBatchDelete *kvrpcpb.RawBatchDeleteResponse RawDeleteRange *kvrpcpb.RawDeleteRangeResponse RawScan *kvrpcpb.RawScanResponse UnsafeDestroyRange *kvrpcpb.UnsafeDestroyRangeResponse Cop *coprocessor.Response CopStream *CopStreamResponse MvccGetByKey *kvrpcpb.MvccGetByKeyResponse MvccGetByStartTS *kvrpcpb.MvccGetByStartTsResponse SplitRegion *kvrpcpb.SplitRegionResponse PessimisticLock *kvrpcpb.PessimisticLockResponse PessimisticRollback *kvrpcpb.PessimisticRollbackResponse DebugGetRegionProperties *debugpb.GetRegionPropertiesResponse Empty *tikvpb.BatchCommandsEmptyResponse }
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
FromBatchCommandsResponse converts a BatchCommands response to Response.
func GenRegionErrorResp ¶
GenRegionErrorResp returns corresponding Response with specified RegionError according to the given req.