forked from p93542168/wheat-cache
595 lines
12 KiB
Go
595 lines
12 KiB
Go
// Code generated by gen-struct. DO NOT EDIT.
|
|
// make gen-service generated
|
|
package persisted
|
|
|
|
import (
|
|
"bytes"
|
|
"encoding/hex"
|
|
"fmt"
|
|
|
|
"gitee.com/wheat-os/wheatCache/pkg/errorx"
|
|
"gitee.com/wheat-os/wheatCache/pkg/proto"
|
|
protobuf "google.golang.org/protobuf/proto"
|
|
)
|
|
|
|
type codecProto struct {
|
|
}
|
|
|
|
func (c *codecProto) Encode(method string, m protobuf.Message) ([]byte, error) {
|
|
buf, err := protobuf.Marshal(m)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
// 16 进制编码
|
|
dst := make([]byte, hex.EncodedLen(len(buf)))
|
|
n := hex.Encode(dst, buf)
|
|
buffer := bytes.NewBuffer(dst[:n])
|
|
buffer.WriteString(fmt.Sprint(":", method))
|
|
|
|
return buffer.Bytes(), nil
|
|
}
|
|
|
|
func (c *codecProto) Decode(buf []byte) (protobuf.Message, error) {
|
|
hexBuf := bytes.Split(buf, []byte(":"))
|
|
if len(hexBuf) != 2 {
|
|
return nil, errorx.New("decode aof err: not a valid aof")
|
|
}
|
|
|
|
method := string(hexBuf[1])
|
|
n, err := hex.Decode(buf, hexBuf[0])
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return decode(method, buf[:n])
|
|
|
|
}
|
|
|
|
func decode(method string, buf []byte) (protobuf.Message, error) {
|
|
switch method {
|
|
case "LIndex":
|
|
return decodeLIndex(buf)
|
|
case "LLen":
|
|
return decodeLLen(buf)
|
|
case "LPop":
|
|
return decodeLPop(buf)
|
|
case "LPush":
|
|
return decodeLPush(buf)
|
|
case "LPushX":
|
|
return decodeLPushX(buf)
|
|
case "LRange":
|
|
return decodeLRange(buf)
|
|
case "LRem":
|
|
return decodeLRem(buf)
|
|
case "LSet":
|
|
return decodeLSet(buf)
|
|
case "RPop":
|
|
return decodeRPop(buf)
|
|
case "LTrim":
|
|
return decodeLTrim(buf)
|
|
case "RPush":
|
|
return decodeRPush(buf)
|
|
case "RPushX":
|
|
return decodeRPushX(buf)
|
|
case "HDel":
|
|
return decodeHDel(buf)
|
|
case "HExists":
|
|
return decodeHExists(buf)
|
|
case "HGet":
|
|
return decodeHGet(buf)
|
|
case "HGetAll":
|
|
return decodeHGetAll(buf)
|
|
case "HIncrBy":
|
|
return decodeHIncrBy(buf)
|
|
case "HKeys":
|
|
return decodeHKeys(buf)
|
|
case "HLen":
|
|
return decodeHLen(buf)
|
|
case "HSet":
|
|
return decodeHSet(buf)
|
|
case "HSetX":
|
|
return decodeHSetX(buf)
|
|
case "CPush":
|
|
return decodeCPush(buf)
|
|
case "CPop":
|
|
return decodeCPop(buf)
|
|
case "CMake":
|
|
return decodeCMake(buf)
|
|
case "CLen":
|
|
return decodeCLen(buf)
|
|
case "CClean":
|
|
return decodeCClean(buf)
|
|
case "Set":
|
|
return decodeSet(buf)
|
|
case "Get":
|
|
return decodeGet(buf)
|
|
case "Add":
|
|
return decodeAdd(buf)
|
|
case "Reduce":
|
|
return decodeReduce(buf)
|
|
case "Setnx":
|
|
return decodeSetnx(buf)
|
|
case "SetBit":
|
|
return decodeSetBit(buf)
|
|
case "GetBit":
|
|
return decodeGetBit(buf)
|
|
case "GetRange":
|
|
return decodeGetRange(buf)
|
|
case "GetSet":
|
|
return decodeGetSet(buf)
|
|
case "StrLen":
|
|
return decodeStrLen(buf)
|
|
case "SAdd":
|
|
return decodeSAdd(buf)
|
|
case "SCard":
|
|
return decodeSCard(buf)
|
|
case "SDiff":
|
|
return decodeSDiff(buf)
|
|
case "SDiffStore":
|
|
return decodeSDiffStore(buf)
|
|
case "SInter":
|
|
return decodeSInter(buf)
|
|
case "SInterStore":
|
|
return decodeSInterStore(buf)
|
|
case "SIsMember":
|
|
return decodeSIsMember(buf)
|
|
case "SMove":
|
|
return decodeSMove(buf)
|
|
case "SPop":
|
|
return decodeSPop(buf)
|
|
case "SRem":
|
|
return decodeSRem(buf)
|
|
case "SUnion":
|
|
return decodeSUnion(buf)
|
|
case "SUnionStore":
|
|
return decodeSUnionStore(buf)
|
|
case "SScan":
|
|
return decodeSScan(buf)
|
|
|
|
}
|
|
|
|
return nil, errorx.New("decode aof err, the method could not be resolved, method:%s", method)
|
|
}
|
|
|
|
func decodeLIndex(buf []byte) (*proto.LIndexRequest, error) {
|
|
req := &proto.LIndexRequest{}
|
|
err := protobuf.Unmarshal(buf, req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return req, nil
|
|
}
|
|
|
|
func decodeLLen(buf []byte) (*proto.LLenRequest, error) {
|
|
req := &proto.LLenRequest{}
|
|
err := protobuf.Unmarshal(buf, req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return req, nil
|
|
}
|
|
|
|
func decodeLPop(buf []byte) (*proto.LPopRequest, error) {
|
|
req := &proto.LPopRequest{}
|
|
err := protobuf.Unmarshal(buf, req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return req, nil
|
|
}
|
|
|
|
func decodeLPush(buf []byte) (*proto.LPushRequest, error) {
|
|
req := &proto.LPushRequest{}
|
|
err := protobuf.Unmarshal(buf, req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return req, nil
|
|
}
|
|
|
|
func decodeLPushX(buf []byte) (*proto.LPushXRequest, error) {
|
|
req := &proto.LPushXRequest{}
|
|
err := protobuf.Unmarshal(buf, req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return req, nil
|
|
}
|
|
|
|
func decodeLRange(buf []byte) (*proto.LRangeRequest, error) {
|
|
req := &proto.LRangeRequest{}
|
|
err := protobuf.Unmarshal(buf, req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return req, nil
|
|
}
|
|
|
|
func decodeLRem(buf []byte) (*proto.LRemRequest, error) {
|
|
req := &proto.LRemRequest{}
|
|
err := protobuf.Unmarshal(buf, req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return req, nil
|
|
}
|
|
|
|
func decodeLSet(buf []byte) (*proto.LSetRequest, error) {
|
|
req := &proto.LSetRequest{}
|
|
err := protobuf.Unmarshal(buf, req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return req, nil
|
|
}
|
|
|
|
func decodeRPop(buf []byte) (*proto.RPopRequest, error) {
|
|
req := &proto.RPopRequest{}
|
|
err := protobuf.Unmarshal(buf, req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return req, nil
|
|
}
|
|
|
|
func decodeLTrim(buf []byte) (*proto.LTrimRequest, error) {
|
|
req := &proto.LTrimRequest{}
|
|
err := protobuf.Unmarshal(buf, req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return req, nil
|
|
}
|
|
|
|
func decodeRPush(buf []byte) (*proto.RPushRequest, error) {
|
|
req := &proto.RPushRequest{}
|
|
err := protobuf.Unmarshal(buf, req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return req, nil
|
|
}
|
|
|
|
func decodeRPushX(buf []byte) (*proto.RPushXRequest, error) {
|
|
req := &proto.RPushXRequest{}
|
|
err := protobuf.Unmarshal(buf, req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return req, nil
|
|
}
|
|
|
|
func decodeHDel(buf []byte) (*proto.HDelRequest, error) {
|
|
req := &proto.HDelRequest{}
|
|
err := protobuf.Unmarshal(buf, req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return req, nil
|
|
}
|
|
|
|
func decodeHExists(buf []byte) (*proto.HExistsRequest, error) {
|
|
req := &proto.HExistsRequest{}
|
|
err := protobuf.Unmarshal(buf, req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return req, nil
|
|
}
|
|
|
|
func decodeHGet(buf []byte) (*proto.HGetRequest, error) {
|
|
req := &proto.HGetRequest{}
|
|
err := protobuf.Unmarshal(buf, req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return req, nil
|
|
}
|
|
|
|
func decodeHGetAll(buf []byte) (*proto.HGetAllRequest, error) {
|
|
req := &proto.HGetAllRequest{}
|
|
err := protobuf.Unmarshal(buf, req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return req, nil
|
|
}
|
|
|
|
func decodeHIncrBy(buf []byte) (*proto.HIncrByRequest, error) {
|
|
req := &proto.HIncrByRequest{}
|
|
err := protobuf.Unmarshal(buf, req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return req, nil
|
|
}
|
|
|
|
func decodeHKeys(buf []byte) (*proto.HKeysRequest, error) {
|
|
req := &proto.HKeysRequest{}
|
|
err := protobuf.Unmarshal(buf, req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return req, nil
|
|
}
|
|
|
|
func decodeHLen(buf []byte) (*proto.HLenRequest, error) {
|
|
req := &proto.HLenRequest{}
|
|
err := protobuf.Unmarshal(buf, req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return req, nil
|
|
}
|
|
|
|
func decodeHSet(buf []byte) (*proto.HSetRequest, error) {
|
|
req := &proto.HSetRequest{}
|
|
err := protobuf.Unmarshal(buf, req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return req, nil
|
|
}
|
|
|
|
func decodeHSetX(buf []byte) (*proto.HSetXRequest, error) {
|
|
req := &proto.HSetXRequest{}
|
|
err := protobuf.Unmarshal(buf, req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return req, nil
|
|
}
|
|
|
|
func decodeCPush(buf []byte) (*proto.CPushRequest, error) {
|
|
req := &proto.CPushRequest{}
|
|
err := protobuf.Unmarshal(buf, req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return req, nil
|
|
}
|
|
|
|
func decodeCPop(buf []byte) (*proto.CPopRequest, error) {
|
|
req := &proto.CPopRequest{}
|
|
err := protobuf.Unmarshal(buf, req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return req, nil
|
|
}
|
|
|
|
func decodeCMake(buf []byte) (*proto.CMakeRequest, error) {
|
|
req := &proto.CMakeRequest{}
|
|
err := protobuf.Unmarshal(buf, req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return req, nil
|
|
}
|
|
|
|
func decodeCLen(buf []byte) (*proto.CLenRequest, error) {
|
|
req := &proto.CLenRequest{}
|
|
err := protobuf.Unmarshal(buf, req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return req, nil
|
|
}
|
|
|
|
func decodeCClean(buf []byte) (*proto.CCleanRequest, error) {
|
|
req := &proto.CCleanRequest{}
|
|
err := protobuf.Unmarshal(buf, req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return req, nil
|
|
}
|
|
|
|
func decodeSet(buf []byte) (*proto.SetRequest, error) {
|
|
req := &proto.SetRequest{}
|
|
err := protobuf.Unmarshal(buf, req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return req, nil
|
|
}
|
|
|
|
func decodeGet(buf []byte) (*proto.GetRequest, error) {
|
|
req := &proto.GetRequest{}
|
|
err := protobuf.Unmarshal(buf, req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return req, nil
|
|
}
|
|
|
|
func decodeAdd(buf []byte) (*proto.AddRequest, error) {
|
|
req := &proto.AddRequest{}
|
|
err := protobuf.Unmarshal(buf, req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return req, nil
|
|
}
|
|
|
|
func decodeReduce(buf []byte) (*proto.ReduceRequest, error) {
|
|
req := &proto.ReduceRequest{}
|
|
err := protobuf.Unmarshal(buf, req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return req, nil
|
|
}
|
|
|
|
func decodeSetnx(buf []byte) (*proto.SetnxRequest, error) {
|
|
req := &proto.SetnxRequest{}
|
|
err := protobuf.Unmarshal(buf, req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return req, nil
|
|
}
|
|
|
|
func decodeSetBit(buf []byte) (*proto.SetBitRequest, error) {
|
|
req := &proto.SetBitRequest{}
|
|
err := protobuf.Unmarshal(buf, req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return req, nil
|
|
}
|
|
|
|
func decodeGetBit(buf []byte) (*proto.GetBitRequest, error) {
|
|
req := &proto.GetBitRequest{}
|
|
err := protobuf.Unmarshal(buf, req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return req, nil
|
|
}
|
|
|
|
func decodeGetRange(buf []byte) (*proto.GetRangeRequest, error) {
|
|
req := &proto.GetRangeRequest{}
|
|
err := protobuf.Unmarshal(buf, req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return req, nil
|
|
}
|
|
|
|
func decodeGetSet(buf []byte) (*proto.GetSetRequest, error) {
|
|
req := &proto.GetSetRequest{}
|
|
err := protobuf.Unmarshal(buf, req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return req, nil
|
|
}
|
|
|
|
func decodeStrLen(buf []byte) (*proto.StrLenRequest, error) {
|
|
req := &proto.StrLenRequest{}
|
|
err := protobuf.Unmarshal(buf, req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return req, nil
|
|
}
|
|
|
|
func decodeSAdd(buf []byte) (*proto.SAddRequest, error) {
|
|
req := &proto.SAddRequest{}
|
|
err := protobuf.Unmarshal(buf, req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return req, nil
|
|
}
|
|
|
|
func decodeSCard(buf []byte) (*proto.SCardRequest, error) {
|
|
req := &proto.SCardRequest{}
|
|
err := protobuf.Unmarshal(buf, req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return req, nil
|
|
}
|
|
|
|
func decodeSDiff(buf []byte) (*proto.SDiffRequest, error) {
|
|
req := &proto.SDiffRequest{}
|
|
err := protobuf.Unmarshal(buf, req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return req, nil
|
|
}
|
|
|
|
func decodeSDiffStore(buf []byte) (*proto.SDiffStoreRequest, error) {
|
|
req := &proto.SDiffStoreRequest{}
|
|
err := protobuf.Unmarshal(buf, req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return req, nil
|
|
}
|
|
|
|
func decodeSInter(buf []byte) (*proto.SInterRequest, error) {
|
|
req := &proto.SInterRequest{}
|
|
err := protobuf.Unmarshal(buf, req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return req, nil
|
|
}
|
|
|
|
func decodeSInterStore(buf []byte) (*proto.SInterStoreRequest, error) {
|
|
req := &proto.SInterStoreRequest{}
|
|
err := protobuf.Unmarshal(buf, req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return req, nil
|
|
}
|
|
|
|
func decodeSIsMember(buf []byte) (*proto.SIsMemberRequest, error) {
|
|
req := &proto.SIsMemberRequest{}
|
|
err := protobuf.Unmarshal(buf, req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return req, nil
|
|
}
|
|
|
|
func decodeSMove(buf []byte) (*proto.SMoveRequest, error) {
|
|
req := &proto.SMoveRequest{}
|
|
err := protobuf.Unmarshal(buf, req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return req, nil
|
|
}
|
|
|
|
func decodeSPop(buf []byte) (*proto.SPopRequest, error) {
|
|
req := &proto.SPopRequest{}
|
|
err := protobuf.Unmarshal(buf, req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return req, nil
|
|
}
|
|
|
|
func decodeSRem(buf []byte) (*proto.SRemRequest, error) {
|
|
req := &proto.SRemRequest{}
|
|
err := protobuf.Unmarshal(buf, req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return req, nil
|
|
}
|
|
|
|
func decodeSUnion(buf []byte) (*proto.SUnionRequest, error) {
|
|
req := &proto.SUnionRequest{}
|
|
err := protobuf.Unmarshal(buf, req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return req, nil
|
|
}
|
|
|
|
func decodeSUnionStore(buf []byte) (*proto.SUnionStoreRequest, error) {
|
|
req := &proto.SUnionStoreRequest{}
|
|
err := protobuf.Unmarshal(buf, req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return req, nil
|
|
}
|
|
|
|
func decodeSScan(buf []byte) (*proto.SScanRequest, error) {
|
|
req := &proto.SScanRequest{}
|
|
err := protobuf.Unmarshal(buf, req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return req, nil
|
|
}
|