Make msgpack codec backwards compatible with version before 2017

This commit is contained in:
ionutboangiu
2023-07-07 11:47:27 -04:00
committed by Dan Christian Bogos
parent cfd9610e4a
commit 9cea5f1f60
2 changed files with 17 additions and 15 deletions

View File

@@ -185,7 +185,7 @@ func (asr *StatASR) Marshal(ms Marshaler) (marshaled []byte, err error) {
// LoadMarshaled is part of StatMetric interface
func (asr *StatASR) LoadMarshaled(ms Marshaler, marshaled []byte) (err error) {
return ms.Unmarshal(marshaled, asr)
return ms.Unmarshal(marshaled, &asr)
}
// GetFilterIDs is part of StatMetric interface
@@ -313,7 +313,7 @@ func (acd *StatACD) Marshal(ms Marshaler) (marshaled []byte, err error) {
return ms.Marshal(acd)
}
func (acd *StatACD) LoadMarshaled(ms Marshaler, marshaled []byte) (err error) {
return ms.Unmarshal(marshaled, acd)
return ms.Unmarshal(marshaled, &acd)
}
// GetFilterIDs is part of StatMetric interface
@@ -441,7 +441,7 @@ func (tcd *StatTCD) Marshal(ms Marshaler) (marshaled []byte, err error) {
}
func (tcd *StatTCD) LoadMarshaled(ms Marshaler, marshaled []byte) (err error) {
return ms.Unmarshal(marshaled, tcd)
return ms.Unmarshal(marshaled, &tcd)
}
// GetFilterIDs is part of StatMetric interface
@@ -564,7 +564,7 @@ func (acc *StatACC) Marshal(ms Marshaler) (marshaled []byte, err error) {
}
func (acc *StatACC) LoadMarshaled(ms Marshaler, marshaled []byte) (err error) {
return ms.Unmarshal(marshaled, acc)
return ms.Unmarshal(marshaled, &acc)
}
// GetFilterIDs is part of StatMetric interface
@@ -690,7 +690,7 @@ func (tcc *StatTCC) Marshal(ms Marshaler) (marshaled []byte, err error) {
}
func (tcc *StatTCC) LoadMarshaled(ms Marshaler, marshaled []byte) (err error) {
return ms.Unmarshal(marshaled, tcc)
return ms.Unmarshal(marshaled, &tcc)
}
// GetFilterIDs is part of StatMetric interface
@@ -818,7 +818,7 @@ func (pdd *StatPDD) Marshal(ms Marshaler) (marshaled []byte, err error) {
return ms.Marshal(pdd)
}
func (pdd *StatPDD) LoadMarshaled(ms Marshaler, marshaled []byte) (err error) {
return ms.Unmarshal(marshaled, pdd)
return ms.Unmarshal(marshaled, &pdd)
}
// GetFilterIDs is part of StatMetric interface
@@ -957,7 +957,7 @@ func (ddc *StatDDC) Marshal(ms Marshaler) (marshaled []byte, err error) {
}
func (ddc *StatDDC) LoadMarshaled(ms Marshaler, marshaled []byte) (err error) {
return ms.Unmarshal(marshaled, ddc)
return ms.Unmarshal(marshaled, &ddc)
}
// GetFilterIDs is part of StatMetric interface
@@ -1088,7 +1088,7 @@ func (sum *StatSum) Marshal(ms Marshaler) (marshaled []byte, err error) {
}
func (sum *StatSum) LoadMarshaled(ms Marshaler, marshaled []byte) (err error) {
return ms.Unmarshal(marshaled, sum)
return ms.Unmarshal(marshaled, &sum)
}
// GetFilterIDs is part of StatMetric interface
@@ -1226,7 +1226,7 @@ func (avg *StatAverage) Marshal(ms Marshaler) (marshaled []byte, err error) {
}
func (avg *StatAverage) LoadMarshaled(ms Marshaler, marshaled []byte) (err error) {
return ms.Unmarshal(marshaled, avg)
return ms.Unmarshal(marshaled, &avg)
}
// GetFilterIDs is part of StatMetric interface
@@ -1372,7 +1372,7 @@ func (dst *StatDistinct) Marshal(ms Marshaler) (marshaled []byte, err error) {
}
func (dst *StatDistinct) LoadMarshaled(ms Marshaler, marshaled []byte) (err error) {
return ms.Unmarshal(marshaled, dst)
return ms.Unmarshal(marshaled, &dst)
}
// GetFilterIDs is part of StatMetric interface

View File

@@ -262,11 +262,13 @@ type CodecMsgpackMarshaler struct {
}
func NewCodecMsgpackMarshaler() *CodecMsgpackMarshaler {
cmm := &CodecMsgpackMarshaler{new(codec.MsgpackHandle)}
mh := cmm.mh
mh := new(codec.MsgpackHandle)
mh.MapType = reflect.TypeOf(map[string]any(nil))
mh.RawToString = true
return cmm
mh.BasicHandle = codec.BasicHandle{
TimeNotBuiltin: true,
}
return &CodecMsgpackMarshaler{mh}
}
func (cmm *CodecMsgpackMarshaler) Marshal(v any) (b []byte, err error) {
@@ -277,7 +279,7 @@ func (cmm *CodecMsgpackMarshaler) Marshal(v any) (b []byte, err error) {
func (cmm *CodecMsgpackMarshaler) Unmarshal(data []byte, v any) error {
dec := codec.NewDecoderBytes(data, cmm.mh)
return dec.Decode(&v)
return dec.Decode(v)
}
type BincMarshaler struct {
@@ -296,7 +298,7 @@ func (bm *BincMarshaler) Marshal(v any) (b []byte, err error) {
func (bm *BincMarshaler) Unmarshal(data []byte, v any) error {
dec := codec.NewDecoderBytes(data, bm.bh)
return dec.Decode(&v)
return dec.Decode(v)
}
type GOBMarshaler struct{}