forked from p93542168/wheat-cache
chore(aof): update aof codec
This commit is contained in:
parent
ce888a1d0e
commit
170ba44d2d
|
@ -12,10 +12,10 @@ import (
|
||||||
protobuf "google.golang.org/protobuf/proto"
|
protobuf "google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
type codec struct {
|
type codecProto struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c codec) Encode(method string, m protobuf.Message) ([]byte, error) {
|
func (c *codecProto) Encode(method string, m protobuf.Message) ([]byte, error) {
|
||||||
buf, err := protobuf.Marshal(m)
|
buf, err := protobuf.Marshal(m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -30,7 +30,7 @@ func (c codec) Encode(method string, m protobuf.Message) ([]byte, error) {
|
||||||
return buffer.Bytes(), nil
|
return buffer.Bytes(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c codec) Decode(buf []byte) (protobuf.Message, error) {
|
func (c *codecProto) Decode(buf []byte) (protobuf.Message, error) {
|
||||||
hexBuf := bytes.Split(buf, []byte(":"))
|
hexBuf := bytes.Split(buf, []byte(":"))
|
||||||
if len(hexBuf) != 2 {
|
if len(hexBuf) != 2 {
|
||||||
return nil, errorx.New("decode aof err: not a valid aof")
|
return nil, errorx.New("decode aof err: not a valid aof")
|
||||||
|
|
|
@ -12,10 +12,10 @@ import (
|
||||||
protobuf "google.golang.org/protobuf/proto"
|
protobuf "google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
type codec struct {
|
type codecProto struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c codec) Encode(method string, m protobuf.Message) ([]byte, error) {
|
func (c *codecProto) Encode(method string, m protobuf.Message) ([]byte, error) {
|
||||||
buf, err := protobuf.Marshal(m)
|
buf, err := protobuf.Marshal(m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -30,7 +30,7 @@ func (c codec) Encode(method string, m protobuf.Message) ([]byte, error) {
|
||||||
return buffer.Bytes(), nil
|
return buffer.Bytes(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c codec) Decode(buf []byte) (protobuf.Message, error) {
|
func (c *codecProto) Decode(buf []byte) (protobuf.Message, error) {
|
||||||
hexBuf := bytes.Split(buf, []byte(":"))
|
hexBuf := bytes.Split(buf, []byte(":"))
|
||||||
if len(hexBuf) != 2 {
|
if len(hexBuf) != 2 {
|
||||||
return nil, errorx.New("decode aof err: not a valid aof")
|
return nil, errorx.New("decode aof err: not a valid aof")
|
||||||
|
|
Loading…
Reference in New Issue