func processGetDataReq(opReq OpReq, client kv.Client) *OpRep { xid := opReq.Hdr.Xid req := opReq.Req.(*GetDataReq) if err := newErrorRepIfInvalidPath(xid, 0, req.Path); err != nil { return err } node, err := client.GetData(req.Path.Value) if err != nil { return newBackendErrorRep(xid, 0, err) } return newRep( xid, 0, errOk, &GetDataRep{ Data: []byte(node.Value), Stat: newStat(node.CreatedIndex, node.ModifiedIndex, len(node.Value)), }, ) }
func processCheckVersionReq(opReq OpReq, client kv.Client) *OpRep { xid := opReq.Hdr.Xid req := opReq.Req.(*CheckVersionReq) if err := newErrorRepIfInvalidPath(xid, 0, req.Path); err != nil { return err } node, err := client.GetData(req.Path.Value) if err != nil { return newBackendErrorRep(xid, 0, err) } if req.Version != int32(node.ModifiedIndex) { return newErrorRep(xid, 0, errBadVersion) } return newRep( xid, 0, errOk, &PingRep{}, ) }