postgresql

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2019 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

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"
	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

func Metrics

func Metrics() []xmetrics.Metric

Metrics returns the Metrics relevant to this package

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 (c *Connection) GetRecordIDs(shard int, limit int, deathDate int64) ([]int, error)

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

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

func NewMeasures(p provider.Provider) Measures

Jump to

Keyboard shortcuts

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