Documentation
¶
Overview ¶
Package pgproxy is a Postgres wire-protocol router. Clients connect with database=dbname@branch; the proxy reads the startup message, resolves the branch to its backend address, rewrites the database param back to the real dbname, replays the startup to the branch backend, and then relays bytes transparently in both directions (SCRAM auth flows untouched).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BranchResolver ¶
BranchResolver maps a branch name to the "host:port" address of its Postgres instance. Implementations must only resolve branches that can accept connections.
type Proxy ¶
type Proxy struct {
Resolver BranchResolver
// DialTimeout bounds the backend dial. Defaults to 5s.
DialTimeout time.Duration
// StartupTimeout bounds the entire startup phase (SSL/GSS negotiation +
// StartupMessage). A client that connects and dribbles bytes — or sends
// nothing — is dropped after this, freeing the goroutine+fd it pins.
// Defaults to 10s; the deadline is cleared once relaying begins.
StartupTimeout time.Duration
// MaxConns caps the number of connections handled concurrently. When the
// cap is reached, further accepts are refused fast (connection closed)
// rather than queued unbounded. Defaults to 256.
MaxConns int
// IdleTimeout closes a relayed session that has seen no bytes in either
// direction for this long, reclaiming abandoned-but-open connections.
// Defaults to 15m.
IdleTimeout time.Duration
// TLSConfig, when set, makes the proxy answer SSLRequest with 'S' and
// upgrade the client connection via a server-side TLS handshake before
// the startup message. When nil (default) SSLRequest is answered 'N' and
// the session stays plaintext. Backend dials are always plaintext
// (branches are local/cluster-internal).
TLSConfig *tls.Config
}
func New ¶
func New(r BranchResolver) *Proxy
type RegistryResolver ¶
RegistryResolver adapts the registry: only ready branches resolve.
func (*RegistryResolver) ResolveBranch ¶
func (r *RegistryResolver) ResolveBranch(name string) (string, error)
Click to show internal directories.
Click to hide internal directories.