postgres

package module
v0.24.0 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: MIT Imports: 15 Imported by: 0

README

postgres

import "github.com/kitsunium/sdk/framework/connectors/postgres"

Package postgres — the credentials a new connection is opened with, read again from the URL each time.

Package postgres is kit's PostgreSQL engine (ADR 0004): the one module a kit product imports to keep a database on PostgreSQL, and the only code of the product that imports a PostgreSQL driver — pgx, through database/sql. The product's main declares the database with it:

import "github.com/kitsunium/sdk/framework/connectors/postgres"

var App = app.NewApp("vigie", intake.Service, desk.Service).With(
	app.Database("database", postgres.Engine()),
)

The database's URL is libpq's, as pgx reads it — postgres://user:password@host:5432/database?sslmode=verify-full, or host=… user=… key=value pairs — in the variable <APP>_<NAME>_URL. Outside dev kit refuses one that does not write its sslmode: pgx's default, prefer, falls back to plaintext, and the weak modes let a network attacker impersonate the server. sslmode=disable is accepted when written, for a private network. The engine reads the URL again before each new connection, so a password rotated where it lives is used by the next one.

Index

Constants

const CodeURLMalformed errs.Code = 266241

CodeURLMalformed identifies a URL the driver cannot read (ADR 0147: layer 4, one PP per connector).

Code 0.4.16.1

func Engine

func Engine() app.Engine

Engine is the PostgreSQL engine, for app.Database.

Generated from docs/api by tools/genindex.

Documentation

Overview

Package postgres — the credentials a new connection is opened with, read again from the URL each time.

Package postgres is kit's PostgreSQL engine (ADR 0004): the one module a kit product imports to keep a database on PostgreSQL, and the only code of the product that imports a PostgreSQL driver — pgx, through database/sql. The product's main declares the database with it:

import "github.com/kitsunium/sdk/framework/connectors/postgres"

var App = app.NewApp("vigie", intake.Service, desk.Service).With(
	app.Database("database", postgres.Engine()),
)

The database's URL is libpq's, as pgx reads it — postgres://user:password@host:5432/database?sslmode=verify-full, or host=… user=… key=value pairs — in the variable <APP>_<NAME>_URL. Outside dev kit refuses one that does not write its sslmode: pgx's default, prefer, falls back to plaintext, and the weak modes let a network attacker impersonate the server. sslmode=disable is accepted when written, for a private network. The engine reads the URL again before each new connection, so a password rotated where it lives is used by the next one.

Index

Constants

View Source
const (
	// CodeURLMalformed identifies a URL the driver cannot read (ADR 0147: layer 4,
	// one PP per connector).
	CodeURLMalformed errs.Code = 0x00_04_10_01 // 0.4.16.1
)

Variables

This section is empty.

Functions

func Engine

func Engine() app.Engine

Engine is the PostgreSQL engine, for app.Database.

Types

This section is empty.

Jump to

Keyboard shortcuts

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