Documentation ¶
Index ¶
- Variables
- func ConvertValueForDb(in interface{}) (interface{}, error)
- func MakePlaceholderList(x int) string
- type BulkDeleteStmt
- type BulkInsertStmt
- type BulkUpdateStmt
- type ChecksumChunk
- type ConfigChunk
- type DBWrapper
- func (dbw *DBWrapper) CompareAndSetConnected(connected bool) (swapped bool)
- func (dbw *DBWrapper) IsConnected() bool
- func (dbw *DBWrapper) SqlBegin(concurrencySafety bool, quiet bool) (DbTransaction, error)
- func (dbw *DBWrapper) SqlBulkDelete(keys []string, stmt *BulkDeleteStmt) error
- func (dbw *DBWrapper) SqlBulkInsert(rows []Row, stmt *BulkInsertStmt) error
- func (dbw *DBWrapper) SqlBulkUpdate(rows []Row, stmt *BulkUpdateStmt) error
- func (dbw *DBWrapper) SqlCommit(tx DbTransaction, quiet bool) error
- func (dbw *DBWrapper) SqlExec(opObserver prometheus.Observer, sql string, args ...interface{}) (sql.Result, error)
- func (dbw *DBWrapper) SqlExecQuiet(opObserver prometheus.Observer, sql string, args ...interface{}) (sql.Result, error)
- func (dbw *DBWrapper) SqlExecTx(tx DbTransaction, opObserver prometheus.Observer, sql string, ...) (sql.Result, error)
- func (dbw *DBWrapper) SqlExecTxQuiet(tx DbTransaction, opObserver prometheus.Observer, sql string, ...) (sql.Result, error)
- func (dbw *DBWrapper) SqlFetchAll(queryObserver prometheus.Observer, query string, args ...interface{}) ([][]interface{}, error)
- func (dbw *DBWrapper) SqlFetchAllQuiet(queryObserver prometheus.Observer, query string, args ...interface{}) ([][]interface{}, error)
- func (dbw *DBWrapper) SqlFetchAllTx(tx DbTransaction, queryObserver prometheus.Observer, query string, ...) ([][]interface{}, error)
- func (dbw *DBWrapper) SqlFetchAllTxQuiet(tx DbTransaction, queryObserver prometheus.Observer, query string, ...) ([][]interface{}, error)
- func (dbw *DBWrapper) SqlFetchChecksums(table string, ids []string) (map[string]map[string]string, error)
- func (dbw *DBWrapper) SqlFetchIds(envId []byte, table string, field string) ([]string, error)
- func (dbw *DBWrapper) SqlQuery(query string, args ...interface{}) (*sql.Rows, error)
- func (dbw *DBWrapper) SqlRollback(tx DbTransaction, quiet bool) error
- func (dbw DBWrapper) SqlTransaction(concurrencySafety bool, retryOnConnectionFailure bool, quiet bool, ...) error
- func (dbw *DBWrapper) WaitForConnection()
- func (dbw *DBWrapper) WithRetry(f func() (sql.Result, error)) (sql.Result, error)
- type DbClient
- type DbClientOrTransaction
- type DbTransaction
- type Icinga2RedisWriter
- type Icinga2RedisWriterEvents
- type Icinga2RedisWriterEventsConfig
- type Icinga2RedisWriterKeyPrefixes
- type Icinga2RedisWriterKeyPrefixesConfig
- type Icinga2RedisWriterKeyPrefixesStatus
- type MysqlConnectionError
- type PipelinerWrapper
- type PubSubWrapper
- type RDBWrapper
- func (rdbw *RDBWrapper) CheckConnection(isTicker bool) bool
- func (rdbw *RDBWrapper) CompareAndSetConnected(connected bool) (swapped bool)
- func (rdbw *RDBWrapper) Eval(script string, keys []string, args ...interface{}) *redis.Cmd
- func (rdbw *RDBWrapper) EvalSha(sha1 string, keys []string, args ...interface{}) *redis.Cmd
- func (rdbw *RDBWrapper) HGetAll(key string) *redis.StringStringMapCmd
- func (rdbw *RDBWrapper) HKeys(key string) *redis.StringSliceCmd
- func (rdbw *RDBWrapper) HMGet(key string, fields ...string) *redis.SliceCmd
- func (rdbw *RDBWrapper) IsConnected() bool
- func (rdbw *RDBWrapper) PipeChecksumChunks(done <-chan struct{}, keys []string, redisKey string) <-chan *ChecksumChunk
- func (rdbw *RDBWrapper) PipeConfigChunks(done <-chan struct{}, keys []string, redisKey string) <-chan *ConfigChunk
- func (rdbw *RDBWrapper) Pipeline() PipelinerWrapper
- func (rdbw *RDBWrapper) Publish(channel string, message interface{}) *redis.IntCmd
- func (rdbw *RDBWrapper) SAdd(key string, members ...interface{}) *redis.IntCmd
- func (rdbw *RDBWrapper) SRem(key string, members ...interface{}) *redis.IntCmd
- func (rdbw *RDBWrapper) ScriptExists(hashes ...string) *redis.BoolSliceCmd
- func (rdbw *RDBWrapper) ScriptLoad(script string) *redis.StringCmd
- func (rdbw *RDBWrapper) Subscribe() PubSubWrapper
- func (rdbw *RDBWrapper) TxPipelined(fn func(pipeliner redis.Pipeliner) error) ([]redis.Cmder, error)
- func (rdbw *RDBWrapper) WaitForConnection()
- func (rdbw *RDBWrapper) XAdd(a *redis.XAddArgs) *redis.StringCmd
- func (rdbw *RDBWrapper) XDel(stream string, ids ...string) *redis.IntCmd
- func (rdbw *RDBWrapper) XRead(args *redis.XReadArgs) *redis.XStreamSliceCmd
- type RedisClient
- type Row
- type RowFactory
- type StatusCmd
Constants ¶
This section is empty.
Variables ¶
var DbBulkDeletes = promauto.NewCounter(prometheus.CounterOpts{
Name: "db_bulk_deletes",
Help: "Database bulk deletes since startup",
})
var DbBulkInserts = promauto.NewCounter(prometheus.CounterOpts{
Name: "db_bulk_inserts",
Help: "Database bulk inserts since startup",
})
var DbBulkUpdates = promauto.NewCounter(prometheus.CounterOpts{
Name: "db_bulk_updates",
Help: "Database bulk updates since startup",
})
var DbFetchChecksums = promauto.NewCounter(prometheus.CounterOpts{
Name: "db_fetch_checksums",
Help: "Database FetchChecksums calls since startup",
})
var DbFetchIds = promauto.NewCounter(prometheus.CounterOpts{
Name: "db_fetch_ids",
Help: "Database FetchId calls since startup",
})
var DbIoSeconds = promauto.NewSummaryVec( prometheus.SummaryOpts{ Name: "db_io_seconds", Help: "Database I/O (s)", }, []string{"backend_type", "operation"}, )
var DbOperationsBegin = promauto.NewCounter(prometheus.CounterOpts{
Name: "db_operations_begin",
Help: "Database begin operations since startup",
})
var DbOperationsCommit = promauto.NewCounter(prometheus.CounterOpts{
Name: "db_operations_commit",
Help: "Database commit operations since startup",
})
var DbOperationsExec = promauto.NewCounter(prometheus.CounterOpts{
Name: "db_operations_exec",
Help: "Database exec operations since startup",
})
var DbOperationsQuery = promauto.NewCounter(prometheus.CounterOpts{
Name: "db_operations_query",
Help: "Database query operations since startup",
})
var DbOperationsRollback = promauto.NewCounter(prometheus.CounterOpts{
Name: "db_operations_rollback",
Help: "Database rollback operations since startup",
})
var DbTransactions = promauto.NewCounter(prometheus.CounterOpts{
Name: "db_transactions",
Help: "Database transactions since startup",
})
var RedisWriter = Icinga2RedisWriter{ Events: Icinga2RedisWriterEvents{ Config: Icinga2RedisWriterEventsConfig{ Dump: "icinga:config:dump", Delete: "icinga:config:delete", Update: "icinga:config:update", }, Stats: "icinga:stats", }, KeyPrefixes: Icinga2RedisWriterKeyPrefixes{ Config: Icinga2RedisWriterKeyPrefixesConfig{ Checksum: "icinga:config:checksum:", Object: "icinga:config:object:", Customvar: "icinga:config:customvar:", }, Status: Icinga2RedisWriterKeyPrefixesStatus{ Object: "icinga:state:object:", }, }, }
Functions ¶
func ConvertValueForDb ¶
func ConvertValueForDb(in interface{}) (interface{}, error)
func MakePlaceholderList ¶
Types ¶
type BulkDeleteStmt ¶
type BulkDeleteStmt struct {
Format string
}
func NewBulkDeleteStmt ¶
func NewBulkDeleteStmt(table string, primaryKey string) *BulkDeleteStmt
type BulkInsertStmt ¶
func NewBulkInsertStmt ¶
func NewBulkInsertStmt(table string, fields []string) *BulkInsertStmt
type BulkUpdateStmt ¶
func NewBulkUpdateStmt ¶
func NewBulkUpdateStmt(table string, fields []string) *BulkUpdateStmt
type ChecksumChunk ¶
type ChecksumChunk struct { Keys []string Checksums []interface{} }
type ConfigChunk ¶
type ConfigChunk struct { Keys []string Configs []interface{} Checksums []interface{} }
type DBWrapper ¶
type DBWrapper struct { Db DbClient ConnectedAtomic *uint32 //uint32 to be able to use atomic operations ConnectionUpCondition *sync.Cond ConnectionLostCounterAtomic *uint32 //uint32 to be able to use atomic operations }
DBWrapper is a database wrapper including helper functions.
func (*DBWrapper) CompareAndSetConnected ¶
func (*DBWrapper) IsConnected ¶
func (*DBWrapper) SqlBegin ¶
func (dbw *DBWrapper) SqlBegin(concurrencySafety bool, quiet bool) (DbTransaction, error)
SqlBegin is a wrapper around Db.BeginTx() for auto-logging.
func (*DBWrapper) SqlBulkDelete ¶
func (dbw *DBWrapper) SqlBulkDelete(keys []string, stmt *BulkDeleteStmt) error
func (*DBWrapper) SqlBulkInsert ¶
func (dbw *DBWrapper) SqlBulkInsert(rows []Row, stmt *BulkInsertStmt) error
func (*DBWrapper) SqlBulkUpdate ¶
func (dbw *DBWrapper) SqlBulkUpdate(rows []Row, stmt *BulkUpdateStmt) error
func (*DBWrapper) SqlCommit ¶
func (dbw *DBWrapper) SqlCommit(tx DbTransaction, quiet bool) error
SqlCommit is a wrapper around tx.Commit() for auto-logging.
func (*DBWrapper) SqlExec ¶
func (dbw *DBWrapper) SqlExec(opObserver prometheus.Observer, sql string, args ...interface{}) (sql.Result, error)
SqlExec is a wrapper around sql.Exec() for auto-logging.
func (*DBWrapper) SqlExecQuiet ¶
func (dbw *DBWrapper) SqlExecQuiet(opObserver prometheus.Observer, sql string, args ...interface{}) (sql.Result, error)
SqlExecQuiet is like SqlExec, but doesn't log or benchmark.
func (*DBWrapper) SqlExecTx ¶
func (dbw *DBWrapper) SqlExecTx(tx DbTransaction, opObserver prometheus.Observer, sql string, args ...interface{}) (sql.Result, error)
SqlExecTx is a wrapper around tx.Exec() for auto-logging.
func (*DBWrapper) SqlExecTxQuiet ¶
func (dbw *DBWrapper) SqlExecTxQuiet(tx DbTransaction, opObserver prometheus.Observer, sql string, args ...interface{}) (sql.Result, error)
SqlExecTxQuiet is like SqlExecTx, but doesn't log or benchmark.
func (*DBWrapper) SqlFetchAll ¶
func (dbw *DBWrapper) SqlFetchAll(queryObserver prometheus.Observer, query string, args ...interface{}) ([][]interface{}, error)
func (*DBWrapper) SqlFetchAllQuiet ¶
func (dbw *DBWrapper) SqlFetchAllQuiet(queryObserver prometheus.Observer, query string, args ...interface{}) ([][]interface{}, error)
func (*DBWrapper) SqlFetchAllTx ¶
func (dbw *DBWrapper) SqlFetchAllTx(tx DbTransaction, queryObserver prometheus.Observer, query string, args ...interface{}) ([][]interface{}, error)
func (*DBWrapper) SqlFetchAllTxQuiet ¶
func (dbw *DBWrapper) SqlFetchAllTxQuiet(tx DbTransaction, queryObserver prometheus.Observer, query string, args ...interface{}) ([][]interface{}, error)
func (*DBWrapper) SqlFetchChecksums ¶
func (*DBWrapper) SqlFetchIds ¶
func (*DBWrapper) SqlRollback ¶
func (dbw *DBWrapper) SqlRollback(tx DbTransaction, quiet bool) error
SqlRollback is a wrapper around tx.Rollback() for auto-logging.
func (DBWrapper) SqlTransaction ¶
func (dbw DBWrapper) SqlTransaction(concurrencySafety bool, retryOnConnectionFailure bool, quiet bool, f func(DbTransaction) error) error
sqlTransaction executes the given function inside a transaction.
func (*DBWrapper) WaitForConnection ¶
func (dbw *DBWrapper) WaitForConnection()
type DbClientOrTransaction ¶
type DbClientOrTransaction interface { Query(query string, args ...interface{}) (*sql.Rows, error) Exec(query string, args ...interface{}) (sql.Result, error) }
DbClientOrTransaction is used in SqlFetchAll and SqlFetchAllQuiet.
type DbTransaction ¶
type DbTransaction interface { DbClientOrTransaction Commit() error Rollback() error }
type Icinga2RedisWriter ¶
type Icinga2RedisWriter struct { Events Icinga2RedisWriterEvents KeyPrefixes Icinga2RedisWriterKeyPrefixes }
type Icinga2RedisWriterEvents ¶
type Icinga2RedisWriterEvents struct { Config Icinga2RedisWriterEventsConfig Stats string }
type Icinga2RedisWriterEventsConfig ¶
type Icinga2RedisWriterEventsConfig struct {
Update, Delete, Dump string
}
type Icinga2RedisWriterKeyPrefixes ¶
type Icinga2RedisWriterKeyPrefixes struct { Config Icinga2RedisWriterKeyPrefixesConfig Status Icinga2RedisWriterKeyPrefixesStatus }
type Icinga2RedisWriterKeyPrefixesConfig ¶
type Icinga2RedisWriterKeyPrefixesConfig struct {
Checksum, Object, Customvar string
}
type Icinga2RedisWriterKeyPrefixesStatus ¶
type Icinga2RedisWriterKeyPrefixesStatus struct {
Object string
}
type MysqlConnectionError ¶
type MysqlConnectionError struct {
// contains filtered or unexported fields
}
func (MysqlConnectionError) Error ¶
func (e MysqlConnectionError) Error() string
type PipelinerWrapper ¶
type PipelinerWrapper struct {
// contains filtered or unexported fields
}
type PubSubWrapper ¶
type PubSubWrapper struct {
// contains filtered or unexported fields
}
func (*PubSubWrapper) Channel ¶
func (psw *PubSubWrapper) Channel() <-chan *redis.Message
func (*PubSubWrapper) ChannelSize ¶
func (psw *PubSubWrapper) ChannelSize(size int) <-chan *redis.Message
func (*PubSubWrapper) Close ¶
func (psw *PubSubWrapper) Close() error
func (*PubSubWrapper) ReceiveMessage ¶
func (psw *PubSubWrapper) ReceiveMessage() (*redis.Message, error)
func (*PubSubWrapper) Subscribe ¶
func (psw *PubSubWrapper) Subscribe(channels ...string) error
type RDBWrapper ¶
type RDBWrapper struct { Rdb RedisClient ConnectedAtomic *uint32 //uint32 to be able to use atomic operations ConnectionUpCondition *sync.Cond ConnectionLostCounterAtomic *uint32 //uint32 to be able to use atomic operations }
RDBWrapper is a redis wrapper including helper functions.
func NewRDBWrapper ¶
func NewRDBWrapper(address string, poolSize int) *RDBWrapper
func (*RDBWrapper) CheckConnection ¶
func (rdbw *RDBWrapper) CheckConnection(isTicker bool) bool
func (*RDBWrapper) CompareAndSetConnected ¶
func (rdbw *RDBWrapper) CompareAndSetConnected(connected bool) (swapped bool)
func (*RDBWrapper) Eval ¶
func (rdbw *RDBWrapper) Eval(script string, keys []string, args ...interface{}) *redis.Cmd
Eval is a wrapper for connection handling.
func (*RDBWrapper) EvalSha ¶
func (rdbw *RDBWrapper) EvalSha(sha1 string, keys []string, args ...interface{}) *redis.Cmd
EvalSha is a wrapper for connection handling.
func (*RDBWrapper) HGetAll ¶
func (rdbw *RDBWrapper) HGetAll(key string) *redis.StringStringMapCmd
HGetAll is a wrapper for auto-logging and connection handling.
func (*RDBWrapper) HKeys ¶
func (rdbw *RDBWrapper) HKeys(key string) *redis.StringSliceCmd
HKeys is a wrapper for connection handling.
func (*RDBWrapper) HMGet ¶
func (rdbw *RDBWrapper) HMGet(key string, fields ...string) *redis.SliceCmd
func (*RDBWrapper) IsConnected ¶
func (rdbw *RDBWrapper) IsConnected() bool
func (*RDBWrapper) PipeChecksumChunks ¶
func (rdbw *RDBWrapper) PipeChecksumChunks(done <-chan struct{}, keys []string, redisKey string) <-chan *ChecksumChunk
func (*RDBWrapper) PipeConfigChunks ¶
func (rdbw *RDBWrapper) PipeConfigChunks(done <-chan struct{}, keys []string, redisKey string) <-chan *ConfigChunk
func (*RDBWrapper) Pipeline ¶
func (rdbw *RDBWrapper) Pipeline() PipelinerWrapper
func (*RDBWrapper) Publish ¶
func (rdbw *RDBWrapper) Publish(channel string, message interface{}) *redis.IntCmd
Publish is a wrapper for connection handling.
func (*RDBWrapper) SAdd ¶
func (rdbw *RDBWrapper) SAdd(key string, members ...interface{}) *redis.IntCmd
SAdd is a wrapper for connection handling.
func (*RDBWrapper) SRem ¶
func (rdbw *RDBWrapper) SRem(key string, members ...interface{}) *redis.IntCmd
SRem is a wrapper for connection handling.
func (*RDBWrapper) ScriptExists ¶
func (rdbw *RDBWrapper) ScriptExists(hashes ...string) *redis.BoolSliceCmd
ScriptExists is a wrapper for connection handling.
func (*RDBWrapper) ScriptLoad ¶
func (rdbw *RDBWrapper) ScriptLoad(script string) *redis.StringCmd
ScriptLoad is a wrapper for connection handling.
func (*RDBWrapper) Subscribe ¶
func (rdbw *RDBWrapper) Subscribe() PubSubWrapper
func (*RDBWrapper) TxPipelined ¶
func (rdbw *RDBWrapper) TxPipelined(fn func(pipeliner redis.Pipeliner) error) ([]redis.Cmder, error)
TxPipelined is a wrapper for auto-logging and connection handling.
func (*RDBWrapper) WaitForConnection ¶
func (rdbw *RDBWrapper) WaitForConnection()
func (*RDBWrapper) XAdd ¶
func (rdbw *RDBWrapper) XAdd(a *redis.XAddArgs) *redis.StringCmd
XAdd is a wrapper for connection handling.
func (*RDBWrapper) XDel ¶
func (rdbw *RDBWrapper) XDel(stream string, ids ...string) *redis.IntCmd
XDel is a wrapper for connection handling.
func (*RDBWrapper) XRead ¶
func (rdbw *RDBWrapper) XRead(args *redis.XReadArgs) *redis.XStreamSliceCmd
XRead is a wrapper for connection handling.
type RedisClient ¶
type RedisClient interface { Ping() *redis.StatusCmd Publish(channel string, message interface{}) *redis.IntCmd XRead(a *redis.XReadArgs) *redis.XStreamSliceCmd XDel(stream string, ids ...string) *redis.IntCmd XAdd(a *redis.XAddArgs) *redis.StringCmd HKeys(key string) *redis.StringSliceCmd HMGet(key string, fields ...string) *redis.SliceCmd HGetAll(key string) *redis.StringStringMapCmd TxPipelined(fn func(redis.Pipeliner) error) ([]redis.Cmder, error) Pipeline() redis.Pipeliner Subscribe(channels ...string) *redis.PubSub Eval(script string, keys []string, args ...interface{}) *redis.Cmd EvalSha(sha1 string, keys []string, args ...interface{}) *redis.Cmd ScriptExists(hashes ...string) *redis.BoolSliceCmd ScriptLoad(script string) *redis.StringCmd SAdd(key string, members ...interface{}) *redis.IntCmd SRem(key string, members ...interface{}) *redis.IntCmd }
type RowFactory ¶
type RowFactory func() Row