common

package
v2.0.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2018 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewRedisPool

func NewRedisPool(redisURL string) *redis.Pool

NewRedisPool returns a new Redis connection pool.

Types

type DBLogger

type DBLogger struct {
	*sqlx.DB
}

DBLogger is a DB wrapper which logs the executed sql queries and their duration.

func OpenDatabase

func OpenDatabase(dsn string) (*DBLogger, error)

OpenDatabase opens the database and performs a ping to make sure the database is up.

func (*DBLogger) Beginx

func (db *DBLogger) Beginx() (*TxLogger, error)

Beginx returns a transaction with logging.

func (*DBLogger) Exec

func (db *DBLogger) Exec(query string, args ...interface{}) (sql.Result, error)

Exec logs the queries executed by the Exec method.

func (*DBLogger) Query

func (db *DBLogger) Query(query string, args ...interface{}) (*sql.Rows, error)

Query logs the queries executed by the Query method.

func (*DBLogger) QueryRowx

func (db *DBLogger) QueryRowx(query string, args ...interface{}) *sqlx.Row

QueryRowx logs the queries executed by the QueryRowx method.

func (*DBLogger) Queryx

func (db *DBLogger) Queryx(query string, args ...interface{}) (*sqlx.Rows, error)

Queryx logs the queries executed by the Queryx method.

type TxLogger

type TxLogger struct {
	*sqlx.Tx
}

TxLogger logs the executed sql queries and their duration.

func (*TxLogger) Exec

func (q *TxLogger) Exec(query string, args ...interface{}) (sql.Result, error)

Exec logs the queries executed by the Exec method.

func (*TxLogger) Query

func (q *TxLogger) Query(query string, args ...interface{}) (*sql.Rows, error)

Query logs the queries executed by the Query method.

func (*TxLogger) QueryRowx

func (q *TxLogger) QueryRowx(query string, args ...interface{}) *sqlx.Row

QueryRowx logs the queries executed by the QueryRowx method.

func (*TxLogger) Queryx

func (q *TxLogger) Queryx(query string, args ...interface{}) (*sqlx.Rows, error)

Queryx logs the queries executed by the Queryx method.

Jump to

Keyboard shortcuts

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