util

package
v0.0.0-...-43a2903 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2018 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExecWithRollback

func ExecWithRollback(db *sql.DB, queries []QueryEntry) (res sql.Result, err error)

ExecWithRollback exeutes or rollbak

func InitLog

func InitLog(file string, level string)

InitLog initials log

func MustExec

func MustExec(db *sql.DB, query string, args ...interface{}) sql.Result

MustExec must execute sql or fatal

func OpenDB

func OpenDB(dsn string, maxIdeleConns int) (*sql.DB, error)

OpenDB opens db

func PushPrometheus

func PushPrometheus(job, addr string, interval time.Duration)

PushPrometheus pushes metrics to Prometheus Pushgateway.

func RunWithRetry

func RunWithRetry(ctx context.Context, retryCnt int, interval time.Duration, f func() error) error

RunWithRetry tries to run func in specified count

Types

type QueryEntry

type QueryEntry struct {
	Query              string
	Args               []interface{}
	ExpectAffectedRows int64
}

QueryEntry is a query

Jump to

Keyboard shortcuts

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