Documentation ¶
Index ¶
- Constants
- func DebugPrintln(localPrefix, str string)
- func DoInLazyTransaction(cb func(tx *LazyTrx) error) error
- func DoInLazyTransactionWithTrx(cb func(tx *LazyTrx) error, trx *LazyTrx) (err error)
- func EscapeString(txt string) string
- func Exec(queryTpl string, args ...interface{}) (sql.Result, error)
- func GetDbName() string
- func LockCycle(lockName, hostname string) (bool, error)
- func LogCycleStart(className, hostname string, instanceIdx int) error
- func LogCycleStop(className, hostname string, instanceIdx int, success int) error
- func Query(queryTpl string, args ...interface{}) (rows *sql.Rows, err error)
- func Setup(dsn string, dbMaxConns uint32) error
- func TplQuery(query string, args ...interface{}) string
- type LazyTrx
- func (p *LazyTrx) AddCommitCallback(cb func())
- func (p *LazyTrx) Begin() error
- func (p *LazyTrx) Commit() error
- func (p *LazyTrx) Exec(queryTpl string, args ...interface{}) (sql.Result, error)
- func (p *LazyTrx) Query(queryTpl string, args ...interface{}) (*sql.Rows, error)
- func (p *LazyTrx) Rollback() error
- type RawData
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 LogCycleStart ¶
func LogCycleStop ¶
Types ¶
Click to show internal directories.
Click to hide internal directories.