本文整理匯總了Golang中github.com/pingcap/kvproto/pkg/kvrpcpb.CmdGetRequest類的典型用法代碼示例。如果您正苦於以下問題:Golang CmdGetRequest類的具體用法?Golang CmdGetRequest怎麽用?Golang CmdGetRequest使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了CmdGetRequest類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: onGet
func (h *rpcHandler) onGet(req *kvrpcpb.CmdGetRequest) *kvrpcpb.CmdGetResponse {
if !h.keyInRegion(req.Key) {
panic("onGet: key not in region")
}
val, err := h.mvccStore.Get(req.Key, req.GetVersion())
if err != nil {
return &kvrpcpb.CmdGetResponse{
Error: convertToKeyError(err),
}
}
return &kvrpcpb.CmdGetResponse{
Value: val,
}
}
示例2: TestSendBySelf
// One normally `Send`.
func (s *testClientSuite) TestSendBySelf(c *C) {
l := startServer(":61234", c, handleRequest)
defer l.Close()
cli := newRPCClient()
req := new(pb.Request)
req.Type = pb.MessageType_CmdGet
getReq := new(pb.CmdGetRequest)
getReq.Key = []byte("a")
ver := uint64(0)
getReq.Version = ver
req.CmdGetReq = getReq
resp, err := cli.SendKVReq(":61234", req, readTimeoutShort)
c.Assert(err, IsNil)
c.Assert(req.GetType(), Equals, resp.GetType())
}