Documentation
¶
Overview ¶
Package db provides database connection management for pgedge-loadgen.
Index ¶
- Constants
- func Connect(ctx context.Context, connString string, appNameSuffix string) (*pgxpool.Pool, error)
- func ConnectSingle(ctx context.Context, connString string, appNameSuffix string) (*pgx.Conn, error)
- func ConnectWithMaxConns(ctx context.Context, connString string, maxConns int32, appNameSuffix string) (*pgxpool.Pool, error)
- func DefaultPoolConfig() *pgxpool.Config
- func DropMetadata(ctx context.Context, pool *pgxpool.Pool) error
- func GetAllMetadata(ctx context.Context, pool *pgxpool.Pool) (map[string]string, error)
- func GetMetadataValue(ctx context.Context, pool *pgxpool.Pool, key string) (string, error)
- func GetMetadataValueConn(ctx context.Context, conn *pgx.Conn, key string) (string, error)
- func MetadataExists(ctx context.Context, pool *pgxpool.Pool) (bool, error)
- func SaveMetadata(ctx context.Context, pool *pgxpool.Pool, app string, targetSize string) error
Constants ¶
const (
// AppNamePrefix is the prefix used for all application names.
AppNamePrefix = "pgedge-loadgen"
)
Variables ¶
This section is empty.
Functions ¶
func ConnectSingle ¶
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 ¶
DefaultPoolConfig returns default connection pool configuration.
func DropMetadata ¶
DropMetadata drops the metadata table.
func GetAllMetadata ¶
GetAllMetadata retrieves all metadata as a map.
func GetMetadataValue ¶
GetMetadataValue retrieves a single metadata value by key.
func GetMetadataValueConn ¶
GetMetadataValueConn retrieves a single metadata value by key using a single connection.
func MetadataExists ¶
MetadataExists checks if the metadata table exists.
Types ¶
This section is empty.