ducky/subscriptions

Paddy 2015-07-13 Parent:b240b6123548 Child:1ff031bebf9e

8:61583c1d3886 Go to Latest

ducky/subscriptions/memstore.go

Create a listener that will create subscriptions. We need a listener (as discussed in c4cfceb2f2fb) that will create a Subscription whenever an auth.Profile is created. This is the beginning of that effort. It hasn't been tested, and all the pieces aren't in place, but it's a rough skeleton. We have a Dockerfile that will correctly build a minimal container for the listener. We have a build-docker.sh script that will correctly build a binary that will be used in the Dockerfile. We have a ca-certificates.crt, which are pulled from Ubuntu, and are necessary before we can safely consume SSL endpoints. We created a small consumer script that listens for events off NSQ, and calls the appropriate endpoint for our Subscriptions API. This is untested, and it doesn't build at the moment, but that's awaiting changes in the code.secondbit.org/auth.hg package. Finally, we have a wrapper.sh file that will expose the Stripe secret key being used from a Kubernetes secret file as an environment variable, instead.

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 }