postgres

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package postgres is the PostgreSQL engine for go-messaging's outbox and inbox.

The package exports:

  • Outbox, the statements outbox.New runs, and Inbox, the statement inbox.New runs
  • Migrations, the outbox's and the inbox's tables as a migration set, named Source and recorded in the history table Table
  • Verify, which prepares the statements against a live schema, and Statements, which lists them
  • Pending, which counts the outbox rows awaiting publication

Schema

The migration set holds both the outbox's table and the inbox's, so one module ships them in one migration. Every object it creates is prefixed messaging_, and a consumer declares the set ahead of its own. An outbox row the relay quarantines stays in messaging_outbox with the time and reason of its quarantine, quarantined_at and quarantine_reason, and is neither claimed again nor counted by Pending. A released migration never changes; a golden-hash test pins each one.

Statements

The statements are authored files compiled through sqlate's query package; every one that writes requires a transaction. Verify is for a consumer's verify stage, after its migrations.

The pgtest package gives each test a throwaway database, for this module's integration suite and a consumer's own.

Index

Constants

View Source
const (
	// Source is the migration set's name and the prefix of every object the
	// set owns.
	Source = "messaging"

	// Table is the history table the set's migrations are recorded in, apart
	// from a consumer's own.
	Table = "messaging_schema_version"
)

Variables

This section is empty.

Functions

func Inbox

func Inbox() inbox.Engine

Inbox returns the inbox's statement for Postgres, for inbox.New.

func Migrations

func Migrations() (migrate.Set, error)

Migrations returns the messaging migration set for Postgres: the outbox's and the inbox's tables. A consumer declares it ahead of its own set in its migrator.

func Outbox

func Outbox() outbox.Engine

Outbox returns the outbox's statements for Postgres, for outbox.New.

func Pending

func Pending(ctx context.Context, sess sqlate.Session) (int, error)

Pending counts the outbox rows awaiting publication, neither published nor quarantined, for a consumer that reports or monitors the outbox's lag.

func Statements

func Statements() []query.Statement

Statements returns the compiled statements in name order, for a consumer that lists the SQL its program runs.

func Verify

func Verify(ctx context.Context, sess sqlate.Session) error

Verify prepares the statements against the schema sess reaches, so a schema without the messaging set, or a set behind these statements, fails at start rather than at the first write or claim. A consumer calls it from its verify stage, after the migrations.

Types

This section is empty.

Directories

Path Synopsis
Package pgtest gives each test its own throwaway Postgres database, so no test depends on the compose stack's database or on another test.
Package pgtest gives each test its own throwaway Postgres database, so no test depends on the compose stack's database or on another test.

Jump to

Keyboard shortcuts

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