application

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package application binds retained PostgreSQL scopes to production application settings. It stays separate from the lightweight testkit/postgres helpers so low-level packages can use schema isolation without an infrastructure cycle.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Application

type Application interface {
	Start(context.Context) error
	Shutdown(context.Context) error
	ShutdownTimeout() time.Duration
	Migrations() []infrastructure.MigrationTarget
}

Application is satisfied by *application.App without importing application assembly into a feature helper. Build it from Environment.Settings through application.Settings.WithDatabaseScopes before handing it to Start.

type Environment

type Environment struct {
	// contains filtered or unexported fields
}

Environment contains scoped copies of every selected logical connection. It owns migration setup and registers bounded application cleanup through Start.

func Bind

func Bind(settings infrastructure.DatabaseSettings, selections ...Selection) (*Environment, error)

Bind requires every configured connection exactly once. Separate Isolate calls express distinct namespaces; one On call expresses intentional sharing. Test pools use two connections per endpoint and retain the configured global ceiling. This neither mutates original settings nor reconfigures a live pool.

func (Environment) Format

func (Environment) Format(s fmt.State, _ rune)

func (*Environment) Migrate

func (e *Environment) Migrate(ctx context.Context, targets ...infrastructure.MigrationTarget) error

Migrate validates all targets first, then applies one registry/history per physical namespace. Each short-lived primary pool closes before the next opens. Successful migrations and data remain committed if a later group fails.

func (*Environment) Settings

Settings returns caller-owned settings; defaults still alias their named pool.

func (*Environment) Start

Start owns cleanup before migration/startup. Framework and explicit domain migrations commit through the ordinary runner before providers start. A failed attempt also shuts down immediately. HTTP/worker lifetimes remain app-owned; register test clients afterward so their cleanup precedes app shutdown.

type Selection

type Selection struct {
	// contains filtered or unexported fields
}

Selection explicitly states which named application connections share a scope. No original deployment endpoint or password survives binding.

func On

func On(scope *pgtest.Scope, names ...database.ConnectionName) Selection

On explicitly maps named application connections to a retained scope.

func (Selection) Format

func (Selection) Format(s fmt.State, _ rune)

func (Selection) WithReads

func (s Selection) WithReads() Selection

WithReads enables a separate bounded read pool against the same opted-in test database/schema. By default all original read routing is explicitly disabled.

Jump to

Keyboard shortcuts

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