Documentation
¶
Overview ¶
Package postgres implements the engines.DatabaseEngine interface for PostgreSQL.
Index ¶
- Constants
- type Engine
- func (e *Engine) Name() string
- func (e *Engine) RequiredCapabilities() []string
- func (e *Engine) Restore(ctx context.Context, c *sandbox.Container, artifactPath string, ...) error
- func (e *Engine) RunCheck(ctx context.Context, c *sandbox.Container, chk contract.Check, ...) (engines.CheckResult, error)
- func (e *Engine) WaitUntilReady(ctx context.Context, c *sandbox.Container, username, database string) error
- type ExecResult
Constants ¶
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 )
const CheckTimeout = 30 * time.Second
CheckTimeout bounds a single SQL check.
const RestoreTimeout = 30 * time.Minute
RestoreTimeout bounds the pg_restore step.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Engine ¶
Engine implements engines.DatabaseEngine for PostgreSQL. It is a thin adapter that binds a *client.Client to the package-level helper functions.
func (*Engine) RequiredCapabilities ¶
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.
type ExecResult ¶
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.