MCPcopy Create free account
hub / github.com/TheThingsNetwork/lorawan-stack / decodeEventData

Function decodeEventData

pkg/events/redis/codec.go:56–69  ·  view source on GitHub ↗
(enc string, evt *ttnpb.Event)

Source from the content-addressed store, hash-verified

54var errUnknownEncoding = errors.DefineInvalidArgument("unknown_encoding", "unknown encoding")
55
56func decodeEventData(enc string, evt *ttnpb.Event) error {
57 if !strings.HasPrefix(enc, protoEncodingPrefix) {
58 return errUnknownEncoding.New()
59 }
60 bpb, err := decodeBinary(strings.TrimPrefix(enc, protoEncodingPrefix))
61 if err != nil {
62 return err
63 }
64 // NOTE: We override the contents of `evt` with the contents `enc` explicitly.
65 // proto.UnmarshalMerge has append semantics for slices, and as such identifiers
66 // and event visibility will be duplicated, as `evt` most likely contains them
67 // from the sparse event representation.
68 return proto.Unmarshal(bpb, evt)
69}
70
71const (
72 eventUIDKey = "event_uid"

Callers 3

subscribeTaskMethod · 0.85
loadEventDataMethod · 0.85
LoadEventMethod · 0.85

Calls 5

decodeBinaryFunction · 0.85
TrimPrefixMethod · 0.80
NewMethod · 0.65
UnmarshalMethod · 0.65
HasPrefixMethod · 0.45

Tested by

no test coverage detected