Documentation ¶
Index ¶
- Constants
- func Metrics() []xmetrics.Metric
- type Config
- type Connection
- func (c *Connection) Close() error
- func (c *Connection) GetBlacklist() (list []blacklist.BlackListedItem, err error)
- func (c *Connection) GetRecordIDs(shard int, limit int, deathDate int64) ([]int, error)
- func (c *Connection) GetRecords(deviceID string, limit int) ([]db.Record, error)
- func (c *Connection) GetRecordsOfType(deviceID string, limit int, eventType db.EventType) ([]db.Record, error)
- func (c *Connection) InsertRecords(records ...db.Record) error
- func (c *Connection) Ping() error
- func (c *Connection) PruneRecords(records []int) error
- func (c *Connection) RemoveAll() error
- type Measures
Constants ¶
View Source
const ( RetryCounter = "retry_count" PoolOpenConnectionsGauge = "pool_open_connections" PoolInUseConnectionsGauge = "pool_in_use_connections" PoolIdleConnectionsGauge = "pool_idle_connections" SQLWaitCounter = "sql_wait_count" SQLWaitDurationCounter = "sql_wait_duration_seconds" SQLMaxIdleClosedCounter = "sql_max_idle_closed" SQLMaxLifetimeClosedCounter = "sql_max_lifetime_closed" SQLQuerySuccessCounter = "sql_query_success_count" SQLQueryFailureCounter = "sql_query_failure_count" SQLInsertedRecordsCounter = "sql_inserted_rows_count" SQLReadRecordsCounter = "sql_read_rows_count" SQLDeletedRecordsCounter = "sql_deleted_rows_count" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct { Server string Username string Database string SSLRootCert string SSLKey string SSLCert string NumRetries int PruneLimit int WaitTimeMult time.Duration ConnectTimeout time.Duration OpTimeout time.Duration // MaxIdleConns sets the max idle connections, the min value is 2 MaxIdleConns int // MaxOpenConns sets the max open connections, to specify unlimited set to 0 MaxOpenConns int PingInterval time.Duration }
Config contains the initial configuration information needed to create a db connection.
type Connection ¶
type Connection struct {
// contains filtered or unexported fields
}
Connection contains the tools to edit the database.
func CreateDbConnection ¶
func CreateDbConnection(config Config, provider provider.Provider, health *health.Health) (*Connection, error)
CreateDbConnection creates db connection and returns the struct to the consumer.
func (*Connection) Close ¶
func (c *Connection) Close() error
func (*Connection) GetBlacklist ¶
func (c *Connection) GetBlacklist() (list []blacklist.BlackListedItem, err error)
GetBlacklist returns a list of blacklisted devices
func (*Connection) GetRecordIDs ¶
func (*Connection) GetRecords ¶
GetRecords returns a list of records for a given device
func (*Connection) GetRecordsOfType ¶
func (c *Connection) GetRecordsOfType(deviceID string, limit int, eventType db.EventType) ([]db.Record, error)
GetRecords returns a list of records for a given device
func (*Connection) InsertRecords ¶
func (c *Connection) InsertRecords(records ...db.Record) error
InsertEvent adds a record to the table.
func (*Connection) Ping ¶
func (c *Connection) Ping() error
func (*Connection) PruneRecords ¶
func (c *Connection) PruneRecords(records []int) error
PruneRecords removes records past their deathdate.
func (*Connection) RemoveAll ¶
func (c *Connection) RemoveAll() error
RemoveAll removes everything in the events table. Used for testing.
type Measures ¶
type Measures struct { Retry xmetrics.Incrementer PoolOpenConnections metrics.Gauge PoolInUseConnections metrics.Gauge PoolIdleConnections metrics.Gauge SQLWaitCount metrics.Counter SQLWaitDuration metrics.Counter SQLMaxIdleClosed metrics.Counter SQLMaxLifetimeClosed metrics.Counter SQLQuerySuccessCount metrics.Counter SQLQueryFailureCount metrics.Counter SQLInsertedRecords metrics.Counter SQLReadRecords metrics.Counter SQLDeletedRecords metrics.Counter }
func NewMeasures ¶
Click to show internal directories.
Click to hide internal directories.