add proto codec.Frame support #45

Merged
vtolstov merged 1 commits from proto-frame into v3 2023-03-05 22:09:54 +03:00
2 changed files with 20 additions and 3 deletions
Showing only changes of commit 6212be1b3b - Show all commits

11
go.mod
View File

@ -1,8 +1,17 @@
module go.unistack.org/micro-codec-msgpack/v3 module go.unistack.org/micro-codec-msgpack/v3
go 1.16 go 1.19
require ( require (
github.com/vmihailenco/msgpack/v5 v5.3.5 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 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
)

View File

@ -5,6 +5,7 @@ import (
"io" "io"
"github.com/vmihailenco/msgpack/v5" "github.com/vmihailenco/msgpack/v5"
pb "go.unistack.org/micro-proto/v3/codec"
"go.unistack.org/micro/v3/codec" "go.unistack.org/micro/v3/codec"
rutil "go.unistack.org/micro/v3/util/reflect" 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 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 return m.Data, nil
} }
@ -52,7 +56,11 @@ func (c *msgpackCodec) Unmarshal(b []byte, v interface{}, opts ...codec.Option)
v = nv 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 m.Data = b
return nil return nil
} }