postgres

package
v1.3.3 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: Apache-2.0, Apache-2.0 Imports: 13 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const SourceType string = "postgres"

Variables

This section is empty.

Functions

func BuildPostgresURL

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"`
	SQLCommenter  *bool             `yaml:"sqlCommenter"`
	// ConnectTimeout optionally bounds how long a single connection attempt may
	// take, in seconds. When unset, no timeout is applied and connection behavior
	// is unchanged.
	ConnectTimeout *int `yaml:"connectTimeout" validate:"omitempty,gte=1"`
	// ReadOnly makes every session read-only (Blitz): writes fail in
	// Postgres itself, and tools that write aren't offered.
	ReadOnly bool `yaml:"readOnly"`
}

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) Close

func (s *Source) Close() error

Close closes the connection pool (Blitz: Toolbox never did).

func (*Source) IsReadOnly

func (s *Source) IsReadOnly() bool

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