postgres

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package postgres provides a PostgreSQL implementation of outbox.Store using database/sql. Use it with any PostgreSQL-compatible driver (lib/pq, jackc/pgx/v5/stdlib, etc.).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateTableSQL

func CreateTableSQL(tableName string) string

CreateTableSQL returns the PostgreSQL DDL for creating the outbox messages table.

func Migrate

func Migrate(ctx context.Context, db osql.Execer, tableName string) error

Migrate creates the outbox messages table if it does not exist. db can be a *sql.DB, *sql.Tx, *sql.Conn or any other type implementing osql.Execer.

Types

type Store

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

Store implements outbox.Store for PostgreSQL.

func New

func New(db *stdsql.DB, options ...osql.Option) *Store

New creates a new PostgreSQL outbox store backed by *sql.DB.

func (*Store) FetchPending

func (s *Store) FetchPending(ctx context.Context, limit int) ([]outbox.Message, error)

FetchPending atomically claims up to limit pending messages for processing using FOR UPDATE SKIP LOCKED so concurrent workers don't collide.

func (*Store) MarkFailed

func (s *Store) MarkFailed(ctx context.Context, id string, err error) error

MarkFailed increments retries and records the error. Sets status to failed when max retries reached, else back to pending.

func (*Store) MarkProcessed

func (s *Store) MarkProcessed(ctx context.Context, ids ...string) error

MarkProcessed marks messages as successfully processed.

func (*Store) Save

func (s *Store) Save(ctx context.Context, tx any, msgs ...outbox.Message) error

Save persists messages within the given transaction. tx may be a *sql.Tx, or nil to have the Store create its own transaction.

Jump to

Keyboard shortcuts

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