datastore

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2018 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// AppDB represents main application database
	AppDB name = iota

	// LogDB represents http logging database
	LogDB
)

Variables

This section is empty.

Functions

This section is empty.

Types

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 NOTE: I have chosen to use the same database for logging as my "main" app database. I'd recommend having a separate db and would have a separate method to start that connection pool up and pass it, but since this is just an example....

func (Datastore) BeginTx

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

BeginTx begins a *sql.Tx for the given db

func (Datastore) DB

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

DB returns an initialized sql.DB given a database name

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