diff --git a/stream/mts/meta/meta.go b/stream/mts/meta/meta.go index bc3a6da6..1e2182c0 100644 --- a/stream/mts/meta/meta.go +++ b/stream/mts/meta/meta.go @@ -56,7 +56,7 @@ var ( // Metadata provides functionality for the storage and encoding of metadata // using a map. -type Metadata struct { +type Data struct { mu sync.RWMutex data map[string]string order []string @@ -64,8 +64,8 @@ type Metadata struct { } // New returns a pointer to a new Metadata. -func New() *Metadata { - return &Metadata{ +func New() *Data { + return &Data{ data: make(map[string]string), enc: []byte{ 0x00, // Reserved byte @@ -77,7 +77,7 @@ func New() *Metadata { } // Add adds metadata with key and val. -func (m *Metadata) Add(key, val string) { +func (m *Data) Add(key, val string) { m.mu.Lock() defer m.mu.Unlock() m.data[key] = val @@ -91,7 +91,7 @@ func (m *Metadata) Add(key, val string) { } // All returns the a copy of the map containing the meta data. -func (m *Metadata) All() map[string]string { +func (m *Data) All() map[string]string { m.mu.Lock() cpy := make(map[string]string) for k, v := range m.data { @@ -102,7 +102,7 @@ func (m *Metadata) All() map[string]string { } // Get returns the meta data for the passed key. -func (m *Metadata) Get(key string) (string, error) { +func (m *Data) Get(key string) (string, error) { m.mu.Lock() val, ok := m.data[key] m.mu.Unlock() @@ -113,7 +113,7 @@ func (m *Metadata) Get(key string) (string, error) { } // Delete deletes a meta entry in the map and returns error if it doesn’t exist. -func (m *Metadata) Delete(key string) error { +func (m *Data) Delete(key string) error { m.mu.Lock() defer m.mu.Unlock() if _, ok := m.data[key]; ok { @@ -132,7 +132,7 @@ func (m *Metadata) Delete(key string) error { // Encode takes the meta data map and encodes into a byte slice with header // describing the version, length of data and data in TSV format. -func (m *Metadata) Encode() []byte { +func (m *Data) Encode() []byte { m.enc = m.enc[:headSize] // Iterate over map and append entries, only adding tab if we're not on the