postgres

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package postgres implements the ditto Engine interface for PostgreSQL. It registers itself via init() so that a blank import in main.go is sufficient to make the engine available.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Engine

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

Engine implements engine.Engine for PostgreSQL.

func (*Engine) ConnectionString

func (e *Engine) ConnectionString(host string, port int) string

func (*Engine) ContainerEnv

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

func (*Engine) ContainerImage

func (e *Engine) ContainerImage() string

func (*Engine) Dump

func (e *Engine) Dump(
	ctx context.Context,
	docker *client.Client,
	clientImage string,
	src engine.SourceConfig,
	destPath string,
	opts engine.DumpOptions,
) error

Dump runs pg_dump inside a short-lived helper container and writes a custom-format compressed dump to destPath. When opts.SchemaOnly is true, --schema-only is passed so only DDL is captured (no row data).

func (*Engine) DumpFromContainer

func (e *Engine) DumpFromContainer(ctx context.Context, docker *client.Client, containerName string, destPath string, opts engine.DumpOptions) error

DumpFromContainer creates a compressed dump of the ditto database running inside containerName and writes it to destPath on the host. The container must have its dump directory mounted at /dump (read-write). When opts.SchemaOnly is true, --schema-only is passed to pg_dump.

func (*Engine) Name

func (e *Engine) Name() string

func (*Engine) Restore

func (e *Engine) Restore(ctx context.Context, docker *client.Client, dumpPath string, containerName string) error

Restore calls pg_restore inside the running container by exec-ing into it. containerName is the Docker container name (e.g. "ditto-<id>") as set by the copy manager. The manager calls WaitReady before Restore, so readiness is already guaranteed when this method is invoked.

func (*Engine) WaitReady

func (e *Engine) WaitReady(port int, timeout time.Duration) error

WaitReady polls port until Postgres is accepting connections or timeout elapses. It first waits for TCP connectivity, then confirms with SELECT 1.

Jump to

Keyboard shortcuts

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