db

package
v0.0.0-...-bcffac6 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2016 License: BSD-2-Clause Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TABLE_STATUS                    = "Status"
	TABLE_LOCKS                     = "Locks"
	TABLE_RESOURCE_SHORTAGE_LOG     = "ResourceShortageLog"
	TABLE_RESOURCE_SHORTAGE_LOG_OLD = "ResourceShortageLog_old"
)
View Source
const (
	QUERY_LOG_CYCLE_START = `INSERT INTO ` + TABLE_STATUS + ` (class_name, instance_idx, hostname, cycle_start_ts)
        VALUES ('#class_name#', #instance_idx#, '#hostname#', NOW())
        ON DUPLICATE KEY UPDATE hostname = '#hostname#', cycle_start_ts = NOW()`

	QUERY_LOG_CYCLE_STOP = `UPDATE ` + TABLE_STATUS + ` SET cycle_stop_ts = NOW(), success = #success#
        WHERE class_name = '#class_name#' AND instance_idx = #instance_idx# AND hostname = '#hostname#'`

	QUERY_SET_LOCK = `UPDATE ` + TABLE_LOCKS + ` SET hostname = '#hostname#', updated = NOW(), updated_ns = #nsec#
		WHERE name = '#lock_name#' AND (hostname = '#hostname#' OR updated < NOW() - INTERVAL 1 MINUTE)`
)

language=SQL

Variables

This section is empty.

Functions

func DebugPrintln

func DebugPrintln(localPrefix, str string)

func DoInLazyTransaction

func DoInLazyTransaction(cb func(tx *LazyTrx) error) error

func DoInLazyTransactionWithTrx

func DoInLazyTransactionWithTrx(cb func(tx *LazyTrx) error, trx *LazyTrx) (err error)

func EscapeString

func EscapeString(txt string) string

grabbed from mymysql examples

func Exec

func Exec(queryTpl string, args ...interface{}) (sql.Result, error)

func GetDbName

func GetDbName() string

func LockCycle

func LockCycle(lockName, hostname string) (bool, error)

func LogCycleStart

func LogCycleStart(className, hostname string, instanceIdx int) error

func LogCycleStop

func LogCycleStop(className, hostname string, instanceIdx int, success int) error

func Query

func Query(queryTpl string, args ...interface{}) (rows *sql.Rows, err error)

func Setup

func Setup(dsn string, dbMaxConns uint32) error

func TplQuery

func TplQuery(query string, args ...interface{}) string

Types

type LazyTrx

type LazyTrx struct {
	Name string
	// contains filtered or unexported fields
}

func (*LazyTrx) AddCommitCallback

func (p *LazyTrx) AddCommitCallback(cb func())

func (*LazyTrx) Begin

func (p *LazyTrx) Begin() error

func (*LazyTrx) Commit

func (p *LazyTrx) Commit() error

func (*LazyTrx) Exec

func (p *LazyTrx) Exec(queryTpl string, args ...interface{}) (sql.Result, error)

func (*LazyTrx) Query

func (p *LazyTrx) Query(queryTpl string, args ...interface{}) (*sql.Rows, error)

func (*LazyTrx) Rollback

func (p *LazyTrx) Rollback() error

type RawData

type RawData struct {
	Data string
}

func INStr

func INStr(args []string) *RawData

func INUint64

func INUint64(args []uint64) *RawData

func QNullInt64

func QNullInt64(arg sql.NullInt64) *RawData

Jump to

Keyboard shortcuts

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