pgclient

package
v0.0.0-...-6ee8545 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2023 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MinPoolSize = 2
)

Variables

View Source
var (
	DefaultApp = fmt.Sprintf("promscale@%s", version.Promscale)
)

Functions

func ReaderPoolAfterConnect

func ReaderPoolAfterConnect(schemaLocker LockFunc) func(context.Context, *pgx.Conn) error

func Validate

func Validate(cfg *Config, lcfg limits.Config) error

func WriterPoolAfterConnect

func WriterPoolAfterConnect(schemaLocker LockFunc, synchronousCommit bool) func(context.Context, *pgx.Conn) error

Types

type Client

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

Client sends Prometheus samples to TimescaleDB

func NewClient

func NewClient(r prometheus.Registerer, cfg *Config, mt tenancy.Authorizer, schemaLocker LockFunc, readOnly bool) (*Client, error)

NewClient creates a new PostgreSQL client

func NewClientWithPool

func NewClientWithPool(r prometheus.Registerer, cfg *Config, numCopiers int, writerPool, readerPool, maintPool *pgxpool.Pool, mt tenancy.Authorizer, readOnly bool) (*Client, error)

NewClientWithPool creates a new PostgreSQL client with an existing connection pool.

func (*Client) Close

func (c *Client) Close()

Close closes the client and performs cleanup

func (*Client) HealthCheck

func (c *Client) HealthCheck() error

HealthCheck checks that the client is properly connected

func (*Client) IngestMetrics

func (c *Client) IngestMetrics(ctx context.Context, r *prompb.WriteRequest) (uint64, uint64, error)

IngestMetrics writes the timeseries object into the DB

func (*Client) IngestTraces

func (c *Client) IngestTraces(ctx context.Context, tr ptrace.Traces) error

IngestTraces writes the traces object into the DB.

func (*Client) InitPromQLEngine

func (c *Client) InitPromQLEngine(cfg *query.Config) error

func (*Client) Inserter

func (c *Client) Inserter() ingestor.DBInserter

func (*Client) LabelsCacheCapacity

func (c *Client) LabelsCacheCapacity() int

func (*Client) MaintenanceConnection

func (c *Client) MaintenanceConnection() pgxconn.PgxConn

func (*Client) MetricNamesCacheCapacity

func (c *Client) MetricNamesCacheCapacity() int

func (*Client) NumCachedLabels

func (c *Client) NumCachedLabels() int

func (*Client) NumCachedMetricNames

func (c *Client) NumCachedMetricNames() int

func (*Client) QueryEngine

func (c *Client) QueryEngine() *promql.Engine

func (*Client) Queryable

func (c *Client) Queryable() promql.Queryable

Queryable returns the Prometheus promql.Queryable interface that's running with the same underlying Querier as the Client.

func (*Client) Read

Read returns the promQL query results

func (*Client) ReadOnlyConnection

func (c *Client) ReadOnlyConnection() pgxconn.PgxConn

type Config

type Config struct {
	CacheConfig             cache.Config
	AppName                 string
	Host                    string
	Port                    int
	User                    string
	Password                string
	Database                string
	SslMode                 string
	DbConnectionTimeout     time.Duration
	IgnoreCompressedChunks  bool
	MetricsAsyncAcks        bool
	TracesAsyncAcks         bool
	WriteConnections        int
	WriterPoolSize          int
	WriterSynchronousCommit bool
	ReaderPoolSize          int
	MaintPoolSize           int
	MaxConnections          int
	UsesHA                  bool
	DbUri                   string
	EnableStatementsCache   bool
	TracesBatchTimeout      time.Duration
	TracesMaxBatchSize      int
	TracesBatchWorkers      int
}

Config for the database.

func ParseFlags

func ParseFlags(fs *flag.FlagSet, cfg *Config) *Config

ParseFlags parses the configuration flags specific to PostgreSQL and TimescaleDB

func (*Config) GetConnectionStr

func (cfg *Config) GetConnectionStr() string

GetConnectionStr returns a Postgres connection string

func (*Config) GetNumCopiers

func (cfg *Config) GetNumCopiers() (int, error)

func (*Config) GetPoolSizes

func (cfg *Config) GetPoolSizes(readOnly bool, dbMaxConns int) (readerPoolSize, writerPoolSize, maintPoolSize int, err error)

GetPoolSizes returns the pool sizes adjusted according to defaults, read only settings, and max connections available.

type LockFunc

type LockFunc = func(ctx context.Context, conn *pgx.Conn) error

LockFunc does connect validation function, useful for things such as acquiring locks that should live the duration of the connection

Jump to

Keyboard shortcuts

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