Compare commits

...

2 Commits
v3.11.26 ... v3

Author SHA1 Message Date
vtolstov
6ed0b0e090 Apply Code Coverage Badge 2024-12-23 18:18:20 +00:00
533b265d19 add codec.RawMessage support
All checks were successful
test / test (push) Successful in 3m41s
coverage / build (push) Successful in 8m22s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-12-23 21:17:32 +03:00
3 changed files with 10 additions and 5 deletions

View File

@ -1,5 +1,5 @@
# Micro
![Coverage](https://img.shields.io/badge/Coverage-44.9%25-yellow)
![Coverage](https://img.shields.io/badge/Coverage-45.1%25-yellow)
Micro is a standard library for microservices.

View File

@ -3,6 +3,8 @@ package codec
import (
"errors"
"gopkg.in/yaml.v3"
)
var (
@ -66,10 +68,10 @@ func (m *RawMessage) MarshalYAML() ([]byte, error) {
}
// UnmarshalYAML sets *m to a copy of data.
func (m *RawMessage) UnmarshalYAML(data []byte) error {
func (m *RawMessage) UnmarshalYAML(n *yaml.Node) error {
if m == nil {
return errors.New("RawMessage UnmarshalYAML on nil pointer")
}
*m = append((*m)[0:0], data...)
*m = append((*m)[0:0], []byte(n.Value)...)
return nil
}

View File

@ -1,5 +1,7 @@
package codec
import "gopkg.in/yaml.v3"
// Frame gives us the ability to define raw data to send over the pipes
type Frame struct {
Data []byte
@ -26,8 +28,9 @@ func (m *Frame) MarshalYAML() ([]byte, error) {
}
// UnmarshalYAML set frame data
func (m *Frame) UnmarshalYAML(data []byte) error {
return m.Unmarshal(data)
func (m *Frame) UnmarshalYAML(n *yaml.Node) error {
m.Data = []byte(n.Value)
return nil
}
// ProtoMessage noop func