Help us shape the future of Go! Take the 2026 Go Developer Survey

dbrepl

package
v1.9.1 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package dbrepl holds the engine-level pieces of Postgres streaming and MySQL binlog replication that the container-backed database emulators share.

Index

Constants

View Source
const PasswordEnv = "REPL_KEY"

PasswordEnv is the container environment variable carrying the replication password into PGReplicaScript.

Variables

View Source
var ErrNotStreaming = errors.New("replication is not running")

ErrNotStreaming is returned when a MySQL replica has no replication channel configured.

Functions

func MySQLChangeSourceSQL

func MySQLChangeSourceSQL(host string, port int, user, pass string) string

MySQLChangeSourceSQL points a MySQL 8 replica at host:port with GTID auto-positioning and starts it.

func MySQLReplicaUserSQL

func MySQLReplicaUserSQL(user, pass string) string

MySQLReplicaUserSQL creates or resets the replication login on a MySQL source.

func PGHBAScript

func PGHBAScript(user string) string

PGHBAScript appends a replication rule for user to the source's pg_hba.conf, once.

func PGReplicaRoleSQL

func PGReplicaRoleSQL(user, pass string) string

PGReplicaRoleSQL creates or resets the replication login on a Postgres source.

func PGReplicaScript

func PGReplicaScript(user string) string

PGReplicaScript is a container entrypoint that seeds an empty PGDATA with pg_basebackup from the source ($1 host, $2 port) before handing over to the image entrypoint.

Types

type Status

type Status struct {
	Message     string
	LagSeconds  float64
	Replicating bool
}

Status is a replica's replication health as reported by its engine.

func InterpretMySQL

func InterpretMySQL(row map[string]string) Status

InterpretMySQL turns a lower-cased SHOW REPLICA STATUS row into a Status.

func QueryStatus

func QueryStatus(ctx context.Context, db *sql.DB, postgres bool) (Status, error)

QueryStatus reads the replication health of a Postgres replica (pg) or a MySQL replica.

Jump to

Keyboard shortcuts

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