Documentation ¶
Index ¶
Constants ¶
View Source
const (
HighQPSMaxOpenConns = 100
)
Variables ¶
This section is empty.
Functions ¶
func NonEmptyOrNil ¶
func NonEmptyOrNil(str string) interface{}
Types ¶
type Config ¶
type Config struct { Username string `default:"root"` Password string `default:"my-secret"` Host string `default:"localhost"` Port int `default:"3306"` DBName string `default:"test_db"` MaxOpenConns int `default:"10"` MaxIdleConns int `default:"10"` MaxLifetime time.Duration `default:"60s"` }
func ConfigFromEnv ¶
func ConfigFromEnv() *Config
func ConfigFromEnvPrefix ¶
type DBExecuter ¶
type DBExecuter interface { Invalidate(func()) error Query(ctx context.Context, unprepared string, args ...interface{}) (*sql.Rows, error) Exec(ctx context.Context, unprepared string, args ...interface{}) (sql.Result, error) Prepare(ctx context.Context, query string) (*sql.Stmt, error) }
DBExecuter wraps transaction and non-transaction db calls
type Manager ¶
type Manager interface { CheckStmts(service string, unprepared map[string]string) (map[string]*sql.Stmt, error) Ping() error Close() GetConn() *sql.DB GetDBExecuter() DBExecuter Transact(txFunc func(DBExecuter) (interface{}, error)) (resp interface{}, err error) }
Manager is an interface to helper functions
func NewMysqlManager ¶
func NewMysqlManagerWithMetrics ¶
func NewMysqlManagerWithMetrics(config *Config, gauge *prometheus.GaugeVec, execCounter *prometheus.CounterVec, execHistogram *prometheus.HistogramVec) (Manager, error)
type RowScanner ¶
type RowScanner interface {
Scan(dest ...interface{}) error
}
Source Files ¶
Click to show internal directories.
Click to hide internal directories.