MCPcopy
hub / github.com/grafana/dskit / Decode

Method Decode

ring/partition_ring_model.go:21–38  ·  view source on GitHub ↗

Decode wraps Codec.Decode and ensure PartitionRingDesc maps are not nil.

(in []byte)

Source from the content-addressed store, hash-verified

19
20// Decode wraps Codec.Decode and ensure PartitionRingDesc maps are not nil.
21func (c *partitionRingCodec) Decode(in []byte) (interface{}, error) {
22 out, err := c.Codec.Decode(in)
23 if err != nil {
24 return out, err
25 }
26
27 // Ensure maps are initialised. This makes working with PartitionRingDesc more convenient.
28 if actual, ok := out.(*PartitionRingDesc); ok {
29 if actual.Partitions == nil {
30 actual.Partitions = map[int32]PartitionDesc{}
31 }
32 if actual.Owners == nil {
33 actual.Owners = map[string]OwnerDesc{}
34 }
35 }
36
37 return out, nil
38}
39
40func GetPartitionRingCodec() codec.Codec {
41 return &partitionRingCodec{

Callers

nothing calls this directly

Calls 1

DecodeMethod · 0.65

Tested by

no test coverage detected