cassandra

package
v0.3.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 21, 2019 License: Apache-2.0 Imports: 11 Imported by: 3

Documentation

Overview

package cassandra provides a way to connect to a cassandra database to keep track of device events.

Index

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

func Metrics

func Metrics() []xmetrics.Metric

Metrics returns the Metrics relevant to this package

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
}

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) Close

func (c *Connection) Close() error

Close closes the database connection.

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

func (c *Connection) GetRecords(deviceID string, limit int) ([]db.Record, error)

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 and event type.

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.

type Measures

type Measures struct {
	PoolInUseConnections metrics.Gauge
	SQLDuration          metrics.Histogram
	SQLQuerySuccessCount metrics.Counter
	SQLQueryFailureCount metrics.Counter
	SQLInsertedRecords   metrics.Counter
	SQLReadRecords       metrics.Counter
	SQLDeletedRecords    metrics.Counter
}

func NewMeasures

func NewMeasures(p provider.Provider) Measures

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL