transaction

package
v1.12.5 Latest Latest
Warning

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

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

Documentation

Overview

Package transaction coordinates PostgreSQL business writes with event delivery.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

Handler commits business writes and the inbox marker in one transaction.

type Store

type Store struct{ DB *sql.DB }

Store uses the same database and transactions as the application's business records.

func (*Store) Enqueue

func (s *Store) Enqueue(ctx context.Context, tx *sql.Tx, stream string, message core.Envelope) error

Enqueue writes a prepared envelope into the caller's business transaction.

func (*Store) FlushOne

func (s *Store) FlushOne(ctx context.Context, runtime *core.Runtime) (bool, error)

FlushOne locks one pending row until persisted publication and commit complete. A crash between acknowledgement and commit can republish the same message ID.

func (*Store) Inbox

func (s *Store) Inbox(handler Handler) core.Handler

Inbox prevents repeated database effects for one service subscription and message. External side effects still need their own idempotency keys.

func (*Store) Migrate

func (s *Store) Migrate(ctx context.Context) error

Migrate creates outbox and inbox tables. Applications control when migrations run.

func (*Store) Relay

func (s *Store) Relay(ctx context.Context, runtime *core.Runtime, onError func(error)) error

Relay polls the outbox. Run it under the application's lifecycle context. OnError receives failures while retries keep the original envelope and ID.

Jump to

Keyboard shortcuts

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