postgres

package
v0.2.32-rc3 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2026 License: MPL-2.0 Imports: 23 Imported by: 0

Documentation

Overview

Package postgres is the PostgreSQL outlet driver: pgx pools opened from a DSN the chassis holds, every dial through the egress guard, `query` in a READ ONLY transaction and `exec` in an explicit one that rolls back when a ceiling is crossed. It registers as driver "postgres" on import.

The bundled chassis includes PostgreSQL as an outlet protocol client, not as a chassis storage backend: this package never registers the database/sql "pgx" driver, so internal persistence stays SQLite unless a downstream overlay supplies Postgres storage independently.

Index

Constants

View Source
const (
	// ExecModeDescribeExec fetches the description every time: one extra
	// round trip, never a stale description, safe behind any pooler. The
	// default — correct first.
	ExecModeDescribeExec = "describe-exec"
	// ExecModeCacheDescribe caches descriptions per connection: one round
	// trip per statement, at the cost that a schema change under a cached
	// statement fails its next execution once. Works behind transaction
	// poolers (no named statements). The optimization to measure against.
	ExecModeCacheDescribe = "cache-describe"
)

Execution modes the node may select (--outlet-pg-exec-mode). Both use the extended protocol; the difference is whether a statement's description (parameter and result types) is fetched on every execution or cached per connection.

Variables

This section is empty.

Functions

func SetExecMode

func SetExecMode(mode string) error

SetExecMode selects the execution mode for pools opened from now on. Called once at boot from the node's configuration.

Types

type Driver

type Driver struct{}

Driver opens pgx pools.

func (Driver) Name

func (Driver) Name() string

Name implements outlet.Driver.

func (Driver) Open

Open parses the DSN into a pool config and creates the pool. Nothing is dialed here (MinConns is 0), so a database that is down surfaces on the first statement, never at open. The DSN must be URL form: the key/value form (`host=... password=...`) has no `://` and would slip past DSN redaction in logs.

The pool config keeps the password for reconnects; a Go string cannot be zeroed. It is never logged and never encoded — pgxpool.Config has no JSON form — and the runtime zeroes the []byte it was handed.

Jump to

Keyboard shortcuts

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