db

package
v1.0.0-beta1 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2026 License: PostgreSQL Imports: 7 Imported by: 0

Documentation

Overview

Package db provides database connection management for pgedge-loadgen.

Index

Constants

View Source
const (
	// AppNamePrefix is the prefix used for all application names.
	AppNamePrefix = "pgedge-loadgen"
)

Variables

This section is empty.

Functions

func Connect

func Connect(ctx context.Context, connString string, appNameSuffix string) (*pgxpool.Pool, error)

Connect establishes a connection pool to the PostgreSQL database.

func ConnectSingle

func ConnectSingle(ctx context.Context, connString string, appNameSuffix string) (*pgx.Conn, error)

ConnectSingle establishes a single database connection (not pooled). This is useful for workers that need dedicated connections with unique application names.

func ConnectWithMaxConns

func ConnectWithMaxConns(ctx context.Context, connString string, maxConns int32, appNameSuffix string) (*pgxpool.Pool, error)

ConnectWithMaxConns establishes a connection pool with a specified max connections.

func DefaultPoolConfig

func DefaultPoolConfig() *pgxpool.Config

DefaultPoolConfig returns default connection pool configuration.

func DropMetadata

func DropMetadata(ctx context.Context, pool *pgxpool.Pool) error

DropMetadata drops the metadata table.

func GetAllMetadata

func GetAllMetadata(ctx context.Context, pool *pgxpool.Pool) (map[string]string, error)

GetAllMetadata retrieves all metadata as a map.

func GetMetadataValue

func GetMetadataValue(ctx context.Context, pool *pgxpool.Pool, key string) (string, error)

GetMetadataValue retrieves a single metadata value by key.

func GetMetadataValueConn

func GetMetadataValueConn(ctx context.Context, conn *pgx.Conn, key string) (string, error)

GetMetadataValueConn retrieves a single metadata value by key using a single connection.

func MetadataExists

func MetadataExists(ctx context.Context, pool *pgxpool.Pool) (bool, error)

MetadataExists checks if the metadata table exists.

func SaveMetadata

func SaveMetadata(ctx context.Context, pool *pgxpool.Pool, app string, targetSize string) error

SaveMetadata saves initialization metadata to the database.

Types

This section is empty.

Jump to

Keyboard shortcuts

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