postgres

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseIsolationLevel added in v0.3.3

func ParseIsolationLevel(level string) sql.IsolationLevel

ParseIsolationLevel converts a string level back to int

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client allows sending batches of Prometheus samples to Postgres.

func NewClient

func NewClient(logger log.Logger, config ClientConfig) *Client

NewClient creates a new Client.

func (Client) Name

func (c Client) Name() string

Name identifies the client as a Postgres client.

func (*Client) PrepareStmt added in v0.3.2

func (c *Client) PrepareStmt(rawStmt string) (*sql.Tx, *sql.Stmt, error)

PrepareStmt within a transaction using the configured isolation level

func (Client) UpdateStats

func (c Client) UpdateStats()

UpdateStats pings the server and updates connection metrics

func (*Client) Write

func (c *Client) Write(metrics metric.Metrics, samples model.Samples) error

Write sends a batch of samples to Postgres.

func (*Client) WriteLabel added in v0.3.3

func (c *Client) WriteLabel(m *model.Metric, stmt *sql.Stmt, t time.Time) (written bool, err error)

WriteLabel using a prepared statement and last seen time

func (*Client) WriteLabels

func (c *Client) WriteLabels(metrics metric.Metrics) error

WriteLabels from a batch write

func (*Client) WriteSample added in v0.3.2

func (c *Client) WriteSample(s *model.Sample, txn *sql.Tx, stmt *sql.Stmt) (written bool, err error)

WriteSample using a prepared statement

func (*Client) WriteSamples

func (c *Client) WriteSamples(samples model.Samples) error

WriteSamples from a batch write

type ClientConfig added in v0.3.3

type ClientConfig struct {
	CacheSize   int
	ConnStr     string
	MaxIdle     int
	MaxOpen     int
	PingCron    string
	PingTimeout time.Duration
	TxIsolation string
}

ClientConfig for Postgres Client

Jump to

Keyboard shortcuts

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