diff --git a/stream/mts/meta.go b/stream/mts/meta.go index 62097d30..8bd5365b 100644 --- a/stream/mts/meta.go +++ b/stream/mts/meta.go @@ -29,6 +29,7 @@ package mts import ( "errors" + "strings" "sync" ) @@ -131,3 +132,14 @@ func (m *Metadata) Encode() []byte { return m.enc } + +func ReadFrom(d []byte, key string) (string, error) { + entries := strings.Split(string(d), "\t") + for _, entry := range entries { + kv := strings.Split(entry, "=") + if kv[0] == key { + return kv[1], nil + } + } + return "", errors.New("could not find key in metadata") +}