datastore

package
v0.1.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 16, 2019 License: MIT Imports: 8 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitCacheDB

func InitCacheDB() option

InitCacheDB initializes the cache database (redis) for the Datastore.

func InitLogDB

func InitLogDB() option

InitLogDB initializes a postgres database for logging HTTP requests To be used with github.com/gilcrest/httplog

Types

type DBName

type DBName int

DBName defines database name

const (
	// AppDB represents main application database
	AppDB DBName = iota

	// LogDB represents http logging database
	LogDB
)

type Datastore

type Datastore struct {
	// contains filtered or unexported fields
}

Datastore struct stores common environment related items

func NewDatastore

func NewDatastore() (*Datastore, error)

NewDatastore initializes the datastore struct

func (Datastore) BeginTx

func (ds Datastore) BeginTx(ctx context.Context, opts *sql.TxOptions, n DBName) (*sql.Tx, error)

BeginTx begins a *sql.Tx for the given db

func (Datastore) DB

func (ds Datastore) DB(n DBName) (*sql.DB, error)

DB returns an initialized sql.DB given a database name

func (*Datastore) Option

func (ds *Datastore) Option(opts ...option) error

Option sets the options specified.

func (Datastore) RedisConn

func (ds Datastore) RedisConn() (redis.Conn, error)

RedisConn gets a connection from ds.cacheDB redis cache

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL