ducky/subscriptions

Paddy 2015-09-27 Parent:b240b6123548 Child:1ff031bebf9e

11:0ae1ff0ee306 Go to Latest

ducky/subscriptions/memstore.go

Add comments, move ChangingSystemProperties to the api package. Add comments to all our exported types and variables in subscription.go, both to make golint happy and because it's good to have comments. Move the subscriptions.ChangingSystemProperties helper to api.changingSystemProperties, because it returns API-specific strings and there's no real reason it has to be in the subscriptions package--everything it needs to work on is exported.

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 func (m *Memstore) Reset() error {
23 m.subscriptionLock.Lock()
24 defer m.subscriptionLock.Unlock()
26 m.subscriptions = map[string]Subscription{}
27 return nil
28 }