add proto codec.Frame support #45
11
go.mod
11
go.mod
@ -1,8 +1,17 @@
|
||||
module go.unistack.org/micro-codec-msgpack/v3
|
||||
|
||||
go 1.16
|
||||
go 1.19
|
||||
|
||||
require (
|
||||
github.com/vmihailenco/msgpack/v5 v5.3.5
|
||||
go.unistack.org/micro-proto/v3 v3.3.1
|
||||
go.unistack.org/micro/v3 v3.10.5
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/golang/protobuf v1.5.2 // indirect
|
||||
github.com/google/gnostic v0.6.9 // indirect
|
||||
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
|
||||
google.golang.org/protobuf v1.28.1 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.0 // indirect
|
||||
)
|
||||
|
12
msgpack.go
12
msgpack.go
@ -5,6 +5,7 @@ import (
|
||||
"io"
|
||||
|
||||
"github.com/vmihailenco/msgpack/v5"
|
||||
pb "go.unistack.org/micro-proto/v3/codec"
|
||||
"go.unistack.org/micro/v3/codec"
|
||||
rutil "go.unistack.org/micro/v3/util/reflect"
|
||||
)
|
||||
@ -31,7 +32,10 @@ func (c *msgpackCodec) Marshal(v interface{}, opts ...codec.Option) ([]byte, err
|
||||
v = nv
|
||||
}
|
||||
|
||||
if m, ok := v.(*codec.Frame); ok {
|
||||
switch m := v.(type) {
|
||||
case *codec.Frame:
|
||||
return m.Data, nil
|
||||
case *pb.Frame:
|
||||
return m.Data, nil
|
||||
}
|
||||
|
||||
@ -52,7 +56,11 @@ func (c *msgpackCodec) Unmarshal(b []byte, v interface{}, opts ...codec.Option)
|
||||
v = nv
|
||||
}
|
||||
|
||||
if m, ok := v.(*codec.Frame); ok {
|
||||
switch m := v.(type) {
|
||||
case *codec.Frame:
|
||||
m.Data = b
|
||||
return nil
|
||||
case *pb.Frame:
|
||||
m.Data = b
|
||||
return nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user