From 8f5a2352b294624bf00390880f82f0f44f70e211 Mon Sep 17 00:00:00 2001 From: saxon Date: Sat, 26 Jan 2019 21:57:14 +1030 Subject: [PATCH] stream/mts: added meta.go file to contain struct and methods relating to Metadata and operations --- stream/mts/encoder.go | 46 ------------------------------------------- 1 file changed, 46 deletions(-) diff --git a/stream/mts/encoder.go b/stream/mts/encoder.go index 9909a0fe..fb2afbed 100644 --- a/stream/mts/encoder.go +++ b/stream/mts/encoder.go @@ -29,10 +29,7 @@ LICENSE package mts import ( - "errors" - "fmt" "io" - "sync" "time" "bitbucket.org/ausocean/av/stream/mts/pes" @@ -93,49 +90,6 @@ const ( // global Meta var meta Meta -type Meta struct { - mu sync.RWMutex - data map[string]string -} - -// Add adds metadata with key and val, if already exists return error -func (m *Meta) Add(key, val string) error { - m.mu.Lock() - if _, exists := m.data[key]; !exists { - return errors.New(fmt.Sprintf("Metadata for: %v already exists", key)) - } - m.data[key] = val - m.mu.Unlock() - return nil -} - -// All returns the a copy of the map containing the meta data -func (m *Meta) All() map[string]string { - var cpy map[string]string - for k, v := range m.data { - cpy[k] = v - } - return cpy -} - -// Get returns the meta data for the passed key -func (m *Meta) Get(key string) (string, error) { - val, ok := m.data[key] - if !ok { - return "", errors.New("Key does not exist in metadata map") - } - return val, nil -} - -// Remove deletes a meta entry in the map and returns error if it doesn’t exist -func (m *Meta) Delete(key string) error { - if _, ok := m.data[key]; ok { - delete(m.data, key) - return nil - } - return errors.New("Trying to delete map entry that doesn't exist") -} - // updateMeta ... func updateMeta(b []byte) error { var p psi.PSIBytes