postgresql

package
v0.0.0-...-cf1b1e8 Latest Latest
Warning

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

Go to latest
Published: May 13, 2022 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var QueueMutex sync.Mutex

QueueMutex is used thread safe operations on promSamples list object.

Functions

func Pop

func Pop() *model.Samples

Pop - Pop first element from list

func Push

func Push(samples *model.Samples)

Push - Push element at then end of list

Types

type Client

type Client struct {
	DB *pgx.Conn
	// contains filtered or unexported fields
}

Client - struct to hold critical values

func NewClient

func NewClient(logger log.Logger, cfg *Config) *Client

NewClient creates a new PostgreSQL client

func (*Client) Close

func (c *Client) Close()

Close - Close database connections

func (*Client) HealthCheck

func (c *Client) HealthCheck() error

HealthCheck implements the healtcheck interface

func (Client) Name

func (c Client) Name() string

Name identifies the client as a PostgreSQL client.

func (*Client) Read

func (c *Client) Read(req *prompb.ReadRequest) (*prompb.ReadResponse, error)

Read implements the Reader interface and reads metrics samples from the database

func (*Client) Write

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

Write implements the Writer interface and writes metric samples to the database

type Config

type Config struct {
	CommitSecs      int
	CommitRows      int
	PGWriters       int
	PGParsers       int
	PartitionScheme string
}

Config for the database

type PGParser

type PGParser struct {
	KeepRunning bool
	Running     bool
	// contains filtered or unexported fields
}

PGParser - Threaded parser

func (*PGParser) PGParserShutdown

func (p *PGParser) PGParserShutdown()

PGParserShutdown is a graceful shutdown

func (*PGParser) RunPGParser

func (p *PGParser) RunPGParser(tid int, partitionScheme string, c *PGWriter)

RunPGParser starts the client and listens for a shutdown call.

type PGWriter

type PGWriter struct {
	DB *pgx.Conn

	KeepRunning bool
	Running     bool

	PGWriterMutex sync.Mutex
	// contains filtered or unexported fields
}

PGWriter - Threaded writer

func (*PGWriter) PGWriterSave

func (c *PGWriter) PGWriterSave()

PGWriterSave save data to DB

func (*PGWriter) PGWriterShutdown

func (c *PGWriter) PGWriterShutdown()

PGWriterShutdown - Set shutdown flag for graceful shutdown

func (*PGWriter) RunPGWriter

func (c *PGWriter) RunPGWriter(l log.Logger, tid int, commitSecs int, commitRows int, Parsers int, partitionScheme string)

RunPGWriter starts the client and listens for a shutdown call.

Jump to

Keyboard shortcuts

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