ducky/subscriptions

Paddy 2015-09-27 Parent:b240b6123548

13:1ff031bebf9e Go to Latest

ducky/subscriptions/memstore.go

Add golint comments. Comment on some more of our exported types, functions, and variables, both to make golint happy and because uncommented code never ever ends well.

History
1 package subscriptions
3 import (
4 "sync"
5 )
7 // Memstore is an in-memory version of our datastores, useful
8 // for testing. It should not be used in production.
9 type Memstore struct {
10 subscriptions map[string]Subscription
11 subscriptionLock sync.RWMutex
12 }
14 // NewMemstore returns a pointer to a Memstore object, ready
15 // to be used as a datastore.
16 func NewMemstore() *Memstore {
17 return &Memstore{
18 subscriptions: map[string]Subscription{},
19 }
20 }
22 // Reset empties all the data from the Memstore. It should only
23 // be used in tests.
24 func (m *Memstore) Reset() error {
25 m.subscriptionLock.Lock()
26 defer m.subscriptionLock.Unlock()
28 m.subscriptions = map[string]Subscription{}
29 return nil
30 }