tidb: github.com/pingcap/tidb/store/tikv/tikvrpc Index | Files

package tikvrpc

import "github.com/pingcap/tidb/store/tikv/tikvrpc"

Index

Package Files

tikvrpc.go

func CheckStreamTimeoutLoop Uses

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 Uses

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

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

type CmdType Uses

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

    CmdCop CmdType = 512 + iota
    CmdCopStream

    CmdMvccGetByKey CmdType = 1024 + iota
    CmdMvccGetByStartTs
    CmdSplitRegion

    CmdDebugGetRegionProperties CmdType = 2048 + iota

    CmdEmpty CmdType = 3072 + iota
)

CmdType values.

func (CmdType) String Uses

func (t CmdType) String() string

type CopStreamResponse Uses

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 Uses

func (resp *CopStreamResponse) Close()

Close closes the CopStreamResponse object.

func (*CopStreamResponse) Recv Uses

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

Recv overrides the stream client Recv() function.

type Lease Uses

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

Lease is used to implement grpc stream timeout.

type Request Uses

type Request struct {
    Type CmdType

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

Request wraps all kv/coprocessor requests.

func NewReplicaReadRequest Uses

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 Uses

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

NewRequest returns new kv rpc request.

func (*Request) BatchGet Uses

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

BatchGet returns BatchGetRequest in request.

func (*Request) BatchRollback Uses

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

BatchRollback returns BatchRollbackRequest in request.

func (*Request) CheckTxnStatus Uses

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

CheckTxnStatus returns CheckTxnStatusRequest in request.

func (*Request) Cleanup Uses

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

Cleanup returns CleanupRequest in request.

func (*Request) Commit Uses

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

Commit returns CommitRequest in request.

func (*Request) Cop Uses

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

Cop returns coprocessor request in request.

func (*Request) DebugGetRegionProperties Uses

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

DebugGetRegionProperties returns GetRegionPropertiesRequest in request.

func (*Request) DeleteRange Uses

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

DeleteRange returns DeleteRangeRequest in request.

func (*Request) Empty Uses

func (req *Request) Empty() *tikvpb.BatchCommandsEmptyRequest

Empty returns BatchCommandsEmptyRequest in request.

func (*Request) GC Uses

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

GC returns GCRequest in request.

func (*Request) Get Uses

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

Get returns GetRequest in request.

func (*Request) IsDebugReq Uses

func (req *Request) IsDebugReq() bool

IsDebugReq check whether the req is debug req.

func (*Request) MvccGetByKey Uses

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

MvccGetByKey returns MvccGetByKeyRequest in request.

func (*Request) MvccGetByStartTs Uses

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

MvccGetByStartTs returns MvccGetByStartTsRequest in request.

func (*Request) PessimisticLock Uses

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

PessimisticLock returns PessimisticLockRequest in request.

func (*Request) PessimisticRollback Uses

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

PessimisticRollback returns PessimisticRollbackRequest in request.

func (*Request) Prewrite Uses

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

Prewrite returns PrewriteRequest in request.

func (*Request) RawBatchDelete Uses

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

RawBatchDelete returns RawBatchDeleteRequest in request.

func (*Request) RawBatchGet Uses

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

RawBatchGet returns RawBatchGetRequest in request.

func (*Request) RawBatchPut Uses

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

RawBatchPut returns RawBatchPutRequest in request.

func (*Request) RawDelete Uses

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

RawDelete returns PrewriteRequest in request.

func (*Request) RawDeleteRange Uses

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

RawDeleteRange returns RawDeleteRangeRequest in request.

func (*Request) RawGet Uses

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

RawGet returns RawGetRequest in request.

func (*Request) RawPut Uses

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

RawPut returns RawPutRequest in request.

func (*Request) RawScan Uses

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

RawScan returns RawScanRequest in request.

func (*Request) ResolveLock Uses

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

ResolveLock returns ResolveLockRequest in request.

func (*Request) Scan Uses

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

Scan returns ScanRequest in request.

func (*Request) ScanLock Uses

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

ScanLock returns ScanLockRequest in request.

func (*Request) SplitRegion Uses

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

SplitRegion returns SplitRegionRequest in request.

func (*Request) ToBatchCommandsRequest Uses

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

ToBatchCommandsRequest converts the request to an entry in BatchCommands request.

func (*Request) TxnHeartBeat Uses

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

TxnHeartBeat returns TxnHeartBeatRequest in request.

func (*Request) UnsafeDestroyRange Uses

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

UnsafeDestroyRange returns UnsafeDestroyRangeRequest in request.

type Response Uses

type Response struct {
    Resp interface{}
}

Response wraps all kv/coprocessor responses.

func CallDebugRPC Uses

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

CallDebugRPC launches a debug rpc call.

func CallRPC Uses

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 Uses

func FromBatchCommandsResponse(res *tikvpb.BatchCommandsResponse_Response) *Response

FromBatchCommandsResponse converts a BatchCommands response to Response.

func GenRegionErrorResp Uses

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

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

func (*Response) GetRegionError Uses

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

GetRegionError returns the RegionError of the underlying concrete response.

Package tikvrpc imports 12 packages (graph) and is imported by 37 packages. Updated 2019-09-12. Refresh now. Tools for package owners.