Documentation
¶
Index ¶
- Constants
- func Metrics() []xmetrics.Metric
- type Config
- type Connection
- func (db *Connection) Close() error
- func (db *Connection) GetBlacklist() (list []blacklist.BlackListedItem, err error)
- func (db *Connection) GetRecords(deviceID string, limit int) ([]Record, error)
- func (db *Connection) GetRecordsOfType(deviceID string, limit int, eventType EventType) ([]Record, error)
- func (db *Connection) InsertRecords(records ...Record) error
- func (db *Connection) Ping() error
- func (db *Connection) PruneRecords(t int64) error
- func (db *Connection) RemoveAll() error
- type EventType
- type Inserter
- type Measures
- type Option
- type Pruner
- type Record
- type RecordGetter
- type RetryInsertService
- type RetryListGService
- type RetryRGService
- type RetryUpdateService
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" SQLQueryRetryCounter = "sql_query_retry_count" SQLDeletedRowsCounter = "sql_deleted_rows_count" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶ added in v0.2.0
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 ¶ added in v0.1.1
type Connection struct {
// contains filtered or unexported fields
}
Connection contains the tools to edit the database.
func CreateDbConnection ¶ added in v0.2.0
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 ¶ added in v0.2.0
func (db *Connection) Close() error
func (*Connection) GetBlacklist ¶ added in v0.3.1
func (db *Connection) GetBlacklist() (list []blacklist.BlackListedItem, err error)
GetBlacklist returns a list of blacklisted devices
func (*Connection) GetRecords ¶ added in v0.2.0
func (db *Connection) GetRecords(deviceID string, limit int) ([]Record, error)
GetRecords returns a list of records for a given device
func (*Connection) GetRecordsOfType ¶ added in v0.2.0
func (db *Connection) GetRecordsOfType(deviceID string, limit int, eventType EventType) ([]Record, error)
GetRecords returns a list of records for a given device
func (*Connection) InsertRecords ¶ added in v0.2.1
func (db *Connection) InsertRecords(records ...Record) error
InsertEvent adds a record to the table.
func (*Connection) Ping ¶ added in v0.2.0
func (db *Connection) Ping() error
func (*Connection) PruneRecords ¶ added in v0.2.0
func (db *Connection) PruneRecords(t int64) error
PruneRecords removes records past their deathdate.
func (*Connection) RemoveAll ¶ added in v0.1.1
func (db *Connection) RemoveAll() error
RemoveAll removes everything in the events table. Used for testing.
type Measures ¶ added in v0.2.0
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 SQLQueryRetryCount metrics.Counter SQLDeletedRows metrics.Counter }
func NewMeasures ¶ added in v0.2.0
type Option ¶ added in v0.4.2
type Option func(r *retryConfig)
func WithInterval ¶ added in v0.4.2
func WithMeasures ¶ added in v0.4.2
func WithRetries ¶ added in v0.4.2
type Record ¶ added in v0.2.0
type Record struct { ID int `json:"id"` Type EventType `json:"type" gorm:"type:int"` DeviceID string `json:"deviceid"` BirthDate int64 `json:"birthdate"` DeathDate int64 `json:"deathdate"` Data []byte `json:"data"` Nonce []byte `json:"nonce"` Alg string `json:"alg"` KID string `json:"kid" gorm:"Column:kid"` }
type RecordGetter ¶ added in v0.2.0
type RetryInsertService ¶ added in v0.2.0
type RetryInsertService struct {
// contains filtered or unexported fields
}
func CreateRetryInsertService ¶ added in v0.2.0
func CreateRetryInsertService(inserter Inserter, options ...Option) RetryInsertService
func (RetryInsertService) InsertRecords ¶ added in v0.2.1
func (ri RetryInsertService) InsertRecords(records ...Record) error
type RetryListGService ¶ added in v0.3.1
type RetryListGService struct {
// contains filtered or unexported fields
}
func CreateRetryListGService ¶ added in v0.3.1
func CreateRetryListGService(listGetter blacklist.Updater, options ...Option) RetryListGService
func (RetryListGService) GetBlacklist ¶ added in v0.3.1
func (ltg RetryListGService) GetBlacklist() (list []blacklist.BlackListedItem, err error)
type RetryRGService ¶ added in v0.2.0
type RetryRGService struct {
// contains filtered or unexported fields
}
func CreateRetryRGService ¶ added in v0.2.0
func CreateRetryRGService(recordGetter RecordGetter, options ...Option) RetryRGService
func (RetryRGService) GetRecords ¶ added in v0.2.0
func (rtg RetryRGService) GetRecords(deviceID string, limit int) ([]Record, error)
func (RetryRGService) GetRecordsOfType ¶ added in v0.2.0
type RetryUpdateService ¶ added in v0.2.0
type RetryUpdateService struct {
// contains filtered or unexported fields
}
func CreateRetryUpdateService ¶ added in v0.2.0
func CreateRetryUpdateService(pruner Pruner, options ...Option) RetryUpdateService
func (RetryUpdateService) PruneRecords ¶ added in v0.2.0
func (ru RetryUpdateService) PruneRecords(t int64) error
Click to show internal directories.
Click to hide internal directories.