mirror of
https://github.com/Icinga/icingadb.git
synced 2026-05-28 04:35:54 -04:00
Use interface DBClient for better testability
This commit is contained in:
parent
07fbfd1f11
commit
e63e745aeb
1 changed files with 4 additions and 1 deletions
5
mysql.go
5
mysql.go
|
|
@ -14,11 +14,14 @@ import (
|
|||
// Either a connection or a transaction
|
||||
type DbClient interface {
|
||||
Query(query string, args ...interface{}) (*sql.Rows, error)
|
||||
Ping() error
|
||||
BeginTx(ctx context.Context, opts *sql.TxOptions) (*sql.Tx, error)
|
||||
Exec(query string, args ...interface{}) (sql.Result, error)
|
||||
}
|
||||
|
||||
// Database wrapper including helper functions
|
||||
type DBWrapper struct {
|
||||
Db *sql.DB
|
||||
Db DbClient
|
||||
ConnectedAtomic *uint32 //uint32 to be able to use atomic operations
|
||||
ConnectionUpCondition *sync.Cond
|
||||
ConnectionLostCounter int
|
||||
|
|
|
|||
Loading…
Reference in a new issue