Documentation ¶
Index ¶
- func MigrateDown(db *sql.DB, steps int, logger kitlog.Logger) error
- func MigrateDownAll(db *sql.DB, logger kitlog.Logger) error
- func MigrateUp(db *sql.DB, logger kitlog.Logger) error
- func NewMigration(dirName, migrationName string, logger kitlog.Logger) error
- func Open(connStr string) (*sqlx.DB, error)
- type Certificate
- type Cursor
- type DB
- func (d *DB) Delete(ctx context.Context, key string) error
- func (d *DB) DeleteData(before time.Time, execute bool) error
- func (d *DB) Get(ctx context.Context, key string) ([]byte, error)
- func (d *DB) Ping() error
- func (d *DB) Put(ctx context.Context, key string, data []byte) error
- func (d *DB) ReadData(communityId string, pageSize uint64, startTime, endTime time.Time, ...) (*Page, error)
- func (d *DB) Start() error
- func (d *DB) Stop() error
- func (d *DB) WriteData(communityId string, data []byte, deviceToken string) error
- type Event
- type Page
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MigrateDown ¶
MigrateDown attempts to run down migrations against Postgres. It takes as parameters an sql.DB instance, the number of steps to run, and a logger instance. Migrations are loaded from a bindata generated module that is compiled into the binary.
func MigrateDownAll ¶
MigrateDownAll attempts to run all down migrations against Postgres. It takes as parameters an sql.DB instance, and a logger instance. Migrations are loaded from a bindata generated module that is compiled into the binary.
func MigrateUp ¶
MigrateUp attempts to run all up migrations against Postgres. Migrations are loaded from a bindata generated module that is compiled into the binary. It takes as parameters an sql.DB instance, and a logger instance.
func NewMigration ¶
NewMigration creates a new pair of files into which an SQL migration should be written. All this is doing is ensuring files created are correctly named.
Types ¶
type Certificate ¶ added in v0.3.12
Certificate is an internal type used for persisting and reading TLS certificates from Postgres
type Cursor ¶ added in v0.0.9
Cursor is an internal type used for serializing or parsing page cursors.
type DB ¶ added in v0.0.9
DB is a struct that wraps an sqlx.DB instance that exposes some methods to read and write data.
func NewDB ¶ added in v0.0.9
NewDB is a constructor that returns a new DB instance for the given configuration. We pass in a connection string for the database, and in addition we can pass in a verbose flag which causes the binary to output more verbose log information.
func (*DB) Delete ¶ added in v0.3.12
Delete is our implementation of the autocert.Cache interface for deleting certificates from some underlying datastore.
func (*DB) DeleteData ¶ added in v0.0.9
DeleteData takes as input a timestamp, and after it is executed will have deleted all events in the database from before the submitted time interval for any policy. This function also takes a `execute` parameter. If set to true the delete operation is performed and committed, but if set to false it is executed without committing the transaction. This allows a caller to see how many events would be deleted.
func (*DB) Get ¶ added in v0.3.12
Get is our implementation of the method defined in the autocert.Cache interface for reading certificates from some underlying datastore.
func (*DB) Ping ¶ added in v0.1.1
Ping attempts to verify a connection to the database is still alive, establishing a connection if necessary by executing a simple select query agianst the DB. Note using DB.Ping() did not work as expected as if there are existing connections in the pool that aren't used it will return no error without actually going to the DB to check.
func (*DB) Put ¶ added in v0.3.12
Put is our implementation of the method defined in the autocert.Cache interface for writing certificates to some underlying datastore.
func (*DB) ReadData ¶ added in v0.0.9
func (d *DB) ReadData(communityId string, pageSize uint64, startTime, endTime time.Time, pageCursor string) (*Page, error)
ReadData returns a list of Event types for the given query parameters.
func (*DB) Start ¶ added in v0.0.9
Start connects to the database, and runs any pending up migrations.
func (*DB) Stop ¶ added in v0.0.9
Stop terminates the DB connection, closing the pool of connections.
func (*DB) WriteData ¶ added in v0.0.9
WriteData is the function that is responsible for writing data to the actual database. Takes as input the id of the policy the policy for which we are storing data and a byte slice containing the encrypted data to be persisted. In addition we also pass in the unique device token.