util

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: 14 Imported by: 0

Documentation

Index

Constants

View Source
const PromNamespace = "promscale"

Variables

View Source
var SharedLeaseFailure = fmt.Errorf("failed to acquire shared lease")

Functions

func ExtractMetricDesc

func ExtractMetricDesc(metric prometheus.Metric) (string, error)

func ExtractMetricValue

func ExtractMetricValue(counterOrGauge prometheus.Metric) (float64, error)

func GetEnvVarName

func GetEnvVarName(prefix, fName string) (envVar string)

GetEnvVarName returns the name of the environment variable used for setting the configuration flag based on a prefix and flag name.

func GetSharedLease

func GetSharedLease(ctx context.Context, conn *pgx.Conn, id int64) error

func HistogramBucketsSaturating

func HistogramBucketsSaturating(start float64, factor float64, max float64) []float64

returns a exponential histogram for a saturating metric. Grows exponentially until max-10, and has another bucket for max. This is done so we can tell from the histogram if the resource was saturated or not.

func IsTimescaleDBInstalled

func IsTimescaleDBInstalled(conn pgxconn.PgxConn) bool

func LabelToPrompbLabels

func LabelToPrompbLabels(l labels.Labels) []prompb.Label

func ParseEnv

func ParseEnv(p string, fs *flag.FlagSet) error

ParseEnv takes a prefix string p and *flag.FlagSet. Each flag in the FlagSet is exposed as an upper case environment variable prefixed with p. Any flag that was not explicitly set by a user is updated to the environment variable, if set.

Note: when run with multiple times with different prefixes on the same FlagSet, precedence will get values set with prefix which is parsed first.

func Pointer

func Pointer[T any](x T) *T

Pointer returns a pointer to the given variabel. Useful in tests for primitive value pointer arguments.

Types

type AdvisoryLock

type AdvisoryLock interface {
	GetAdvisoryLock() (bool, error)
	GetSharedAdvisoryLock() (bool, error)
	Unlock() (bool, error)
	UnlockShared() (bool, error)
	Close()
}

type AfterConnectFunc

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

type ManualTicker

type ManualTicker struct {
	C chan time.Time
}

func NewManualTicker

func NewManualTicker(channelSize int) *ManualTicker

func (*ManualTicker) Channel

func (m *ManualTicker) Channel() <-chan time.Time

func (*ManualTicker) Stop

func (m *ManualTicker) Stop()

func (*ManualTicker) Tick

func (m *ManualTicker) Tick()

func (*ManualTicker) Wait

func (m *ManualTicker) Wait()

type PgAdvisoryLock

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

func NewPgAdvisoryLock

func NewPgAdvisoryLock(groupLockID int64, connStr string) (*PgAdvisoryLock, error)

NewPgAdvisoryLock creates a new instance with specified lock ID, connection pool and lock timeout.

func (*PgAdvisoryLock) Close

func (l *PgAdvisoryLock) Close()

Close cleans up the connection

func (*PgAdvisoryLock) Conn

func (l *PgAdvisoryLock) Conn() (*pgx.Conn, error)

func (*PgAdvisoryLock) GetAdvisoryLock

func (l *PgAdvisoryLock) GetAdvisoryLock() (bool, error)

func (*PgAdvisoryLock) GetSharedAdvisoryLock

func (l *PgAdvisoryLock) GetSharedAdvisoryLock() (bool, error)

func (*PgAdvisoryLock) Unlock

func (l *PgAdvisoryLock) Unlock() (bool, error)

func (*PgAdvisoryLock) UnlockShared

func (l *PgAdvisoryLock) UnlockShared() (bool, error)

type Ticker

type Ticker interface {
	Channel() <-chan time.Time
	Stop()
}

func NewTicker

func NewTicker(d time.Duration) Ticker

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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