Documentation ¶
Overview ¶
package cassandra provides a way to connect to a cassandra database to keep track of device events.
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) GetDeviceList(startDate time.Time, endDate time.Time, offset int, limit int) ([]string, error)
- func (c *Connection) GetRecords(deviceID string, limit int, stateHash string) ([]db.Record, error)
- func (c *Connection) GetRecordsOfType(deviceID string, limit int, eventType db.EventType, stateHash string) ([]db.Record, error)
- func (c *Connection) GetStateHash(records []db.Record) (string, error)
- func (c *Connection) InsertRecords(records ...db.Record) error
- func (c *Connection) Ping() 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" SQLDurationSeconds = "sql_duration_seconds" 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" )
View Source
const CountLabel = "count"
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct { // Hosts to connect to. Must have at least one Hosts []string // Database aka Keyspace for cassandra Database string // OpTimeout OpTimeout time.Duration // SSLRootCert used for enabling tls to the cluster. SSLKey, and SSLCert must also be set. SSLRootCert string // SSLKey used for enabling tls to the cluster. SSLRootCert, and SSLCert must also be set. SSLKey string // SSLCert used for enabling tls to the cluster. SSLRootCert, and SSLRootCert must also be set. SSLCert string // If you want to verify the hostname and server cert (like a wildcard for cass cluster) then you should turn this on // This option is basically the inverse of InSecureSkipVerify // See InSecureSkipVerify in http://golang.org/pkg/crypto/tls/ for more info EnableHostVerification bool // Username to authenticate into the cluster. Password must also be provided. Username string // Password to authenticate into the cluster. Username must also be provided. Password string // NumRetries for connecting to the db NumRetries int // WaitTimeMult the amount of time to wait before retrying to connect to the db WaitTimeMult time.Duration // MaxConnsPerHost max number of connections per host MaxConnsPerHost int }
type Connection ¶
type Connection struct {
// contains filtered or unexported fields
}
func CreateDbConnection ¶
func CreateDbConnection(config Config, provider provider.Provider, health *health.Health) (*Connection, error)
func (*Connection) GetBlacklist ¶
func (c *Connection) GetBlacklist() (list []blacklist.BlackListedItem, err error)
GetBlacklist returns a list of blacklisted devices.
func (*Connection) GetDeviceList ¶
func (c *Connection) GetDeviceList(startDate time.Time, endDate time.Time, offset int, limit int) ([]string, error)
GetDeviceList returns a list of device ids where the device id is greater than the offset device id.
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, stateHash string) ([]db.Record, error)
GetRecords returns a list of records for a given device and event type.
func (*Connection) GetStateHash ¶ added in v0.5.0
func (c *Connection) GetStateHash(records []db.Record) (string, error)
GetStateHash returns a hash for the latest record added to the database.
func (*Connection) InsertRecords ¶
func (c *Connection) InsertRecords(records ...db.Record) error
InsertEvent adds a list of records to the table.
func (*Connection) Ping ¶
func (c *Connection) Ping() error
Ping is for pinging the database to verify that the connection is still good.
Click to show internal directories.
Click to hide internal directories.