postgres

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package postgres implements the engines.DatabaseEngine interface for PostgreSQL.

Index

Constants

View Source
const (
	// ReadinessTimeout bounds how long waitUntilReady will poll
	// for a stable server before giving up.
	ReadinessTimeout = 120 * time.Second

	// ReadinessPollInterval is the delay between attempts.
	ReadinessPollInterval = 250 * time.Millisecond
)
View Source
const CheckTimeout = 30 * time.Second

CheckTimeout bounds a single SQL check.

View Source
const RestoreTimeout = 30 * time.Minute

RestoreTimeout bounds the pg_restore step.

Variables

This section is empty.

Functions

This section is empty.

Types

type Engine

type Engine struct {
	CLI *client.Client
}

Engine implements engines.DatabaseEngine for PostgreSQL. It is a thin adapter that binds a *client.Client to the package-level helper functions.

func NewEngine

func NewEngine(cli *client.Client) *Engine

NewEngine returns a new PostgreSQL engine bound to the given Docker client.

func (*Engine) Name

func (e *Engine) Name() string

Name returns the engine identifier.

func (*Engine) RequiredCapabilities

func (e *Engine) RequiredCapabilities() []string

RequiredCapabilities returns the minimal set of Linux capabilities the official postgres image needs at startup.

func (*Engine) Restore

func (e *Engine) Restore(ctx context.Context, c *sandbox.Container, artifactPath string, opts contract.Test) error

Restore loads the artifact into the target database using the contract's restore options.

func (*Engine) RunCheck

RunCheck executes a single SQL validation check.

func (*Engine) WaitUntilReady

func (e *Engine) WaitUntilReady(ctx context.Context, c *sandbox.Container, username, database string) error

WaitUntilReady polls pg_isready until the server accepts connections or the timeout is reached.

type ExecResult

type ExecResult struct {
	ExitCode int
	Stdout   string
	Stderr   string
}

ExecResult captures the outcome of a single command executed inside a running container.

func ExecInContainer

func ExecInContainer(ctx context.Context, cli *client.Client, containerID string, cmd []string, timeout time.Duration) (*ExecResult, error)

ExecInContainer runs cmd inside the given container and returns the demultiplexed stdout/stderr and exit code.

The context deadline (if any) bounds the whole operation. A separate timeout is applied to the attach/read step to avoid hanging on a dead container.

Jump to

Keyboard shortcuts

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