postgres

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: May 21, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const SourceType string = "postgres"

Variables

This section is empty.

Functions

func BuildPostgresURL added in v1.2.0

func BuildPostgresURL(host, port, user, pass, dbname string, queryParams map[string]string) string

BuildPostgresURL assembles a postgres connection URL from its components. It uses net.JoinHostPort so IPv6 host literals are wrapped in brackets as required by RFC 3986 (e.g. "[::1]:5432"); IPv4 addresses and hostnames are left unchanged. Query parameters are encoded with url.Values so special characters are escaped correctly and the output is deterministic.

func ParseQueryExecMode

func ParseQueryExecMode(queryExecMode string) (pgx.QueryExecMode, error)

Types

type Config

type Config struct {
	Name          string            `yaml:"name" validate:"required"`
	Type          string            `yaml:"type" validate:"required"`
	Host          string            `yaml:"host" validate:"required"`
	Port          string            `yaml:"port" validate:"required"`
	User          string            `yaml:"user" validate:"required"`
	Password      string            `yaml:"password" validate:"required"`
	Database      string            `yaml:"database" validate:"required"`
	QueryParams   map[string]string `yaml:"queryParams"`
	QueryExecMode string            `yaml:"queryExecMode" validate:"omitempty,oneof=cache_statement cache_describe describe_exec exec simple_protocol"`
}

func (Config) Initialize

func (r Config) Initialize(ctx context.Context, tracer trace.Tracer) (sources.Source, error)

func (Config) SourceConfigType

func (r Config) SourceConfigType() string

type Source

type Source struct {
	Config
	Pool *pgxpool.Pool
}

func (*Source) PostgresPool

func (s *Source) PostgresPool() *pgxpool.Pool

func (*Source) RunSQL

func (s *Source) RunSQL(ctx context.Context, statement string, params []any) (any, error)

func (*Source) SourceType

func (s *Source) SourceType() string

func (*Source) ToConfig

func (s *Source) ToConfig() sources.SourceConfig

Jump to

Keyboard shortcuts

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