package subscriptions

import (
	"sync"
)

// Memstore is an in-memory version of our datastores, useful
// for testing. It should not be used in production.
type Memstore struct {
	subscriptions    map[string]Subscription
	subscriptionLock sync.RWMutex
}

// NewMemstore returns a pointer to a Memstore object, ready
// to be used as a datastore.
func NewMemstore() *Memstore {
	return &Memstore{
		subscriptions: map[string]Subscription{},
	}
}

func (m *Memstore) reset() error {
	m.subscriptionLock.Lock()
	defer m.subscriptionLock.Unlock()

	m.subscriptions = map[string]Subscription{}
	return nil
}
