ducky/subscriptions

Paddy 2015-09-27 Parent:f1a22fc2321d

11:0ae1ff0ee306 Go to Latest

ducky/subscriptions/postgres.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 "database/sql"
5 )
7 // NewPostgres returns a usable Postgres instance, if and only
8 // if error is nil. If error is not nil, the returned Postgres
9 // instance should not be used.
10 func NewPostgres(conn string) (Postgres, error) {
11 db, err := sql.Open("postgres", conn)
12 if err != nil {
13 return Postgres{}, err
14 }
15 return Postgres{db}, nil
16 }
18 // Postgres represents a thin wrapper around *sql.DB, so we can
19 // inherit its methods but also define our own (so we can fulfill
20 // our subscriptionStore interface on Postgres). Note that the
21 // value of a Postgres variable contains a _pointer_ to an sql.DB
22 // pool of connections, so it's not necessary to use the address of
23 // the Postgres variable itself (though there shouldn't be any harm
24 // in doing so).
25 type Postgres struct {
26 *sql.DB
27 }