fix proto codec
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
parent
5ebe248b19
commit
12e4c80d1a
@ -38,14 +38,14 @@ func (c *protoCodec) Marshal(v interface{}, opts ...codec.Option) ([]byte, error
|
|||||||
return m.Data, nil
|
return m.Data, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
switch v.(type) {
|
switch m := v.(type) {
|
||||||
case proto.Message, newproto.Message:
|
case proto.Message:
|
||||||
break
|
return proto.Marshal(m)
|
||||||
default:
|
case newproto.Message:
|
||||||
return nil, codec.ErrInvalidMessage
|
return proto.Marshal(m)
|
||||||
}
|
}
|
||||||
|
|
||||||
return proto.Marshal(v.(proto.Message))
|
return nil, codec.ErrInvalidMessage
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *protoCodec) Unmarshal(d []byte, v interface{}, opts ...codec.Option) error {
|
func (c *protoCodec) Unmarshal(d []byte, v interface{}, opts ...codec.Option) error {
|
||||||
@ -67,14 +67,15 @@ func (c *protoCodec) Unmarshal(d []byte, v interface{}, opts ...codec.Option) er
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
switch v.(type) {
|
switch m := v.(type) {
|
||||||
case proto.Message, newproto.Message:
|
case proto.Message:
|
||||||
break
|
return proto.Unmarshal(d, m)
|
||||||
default:
|
case newproto.Message:
|
||||||
return codec.ErrInvalidMessage
|
return proto.Unmarshal(d, m)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return proto.Unmarshal(d, v.(proto.Message))
|
return codec.ErrInvalidMessage
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *protoCodec) ReadHeader(conn io.Reader, m *codec.Message, t codec.MessageType) error {
|
func (c *protoCodec) ReadHeader(conn io.Reader, m *codec.Message, t codec.MessageType) error {
|
||||||
|
Loading…
Reference in New Issue
Block a user