Documentation
¶
Overview ¶
Package outboxpostgres provides a supported-adapter Postgres transactional outbox.
Use New with a ports.DatabasePool and Options when async workers need an async.Store backed by Postgres. Store preserves enqueue, lease, complete, retry/dead-letter, stuck-lease recovery, table-name validation, and readiness health behavior.
Events must pass validation before enqueue. Failure messages are kept low-secret and lease completion requires the current lease owner so stale workers cannot complete another worker's job.
Index ¶
- Variables
- type Event
- type Options
- type Store
- func (s *Store) Complete(ctx context.Context, id string) error
- func (s *Store) Enqueue(ctx context.Context, event Event) error
- func (s *Store) Fail(ctx context.Context, id string, _ string) error
- func (s *Store) HealthChecker() ports.HealthChecker
- func (s *Store) Lease(ctx context.Context, limit int) ([]async.Job, error)
Constants ¶
This section is empty.
Variables ¶
var ( // ErrEventNotFound reports that an outbox event was not found for the current lease owner. ErrEventNotFound = errors.New("outbox event not found") // ErrInvalidEvent reports that an outbox event is missing required fields. ErrInvalidEvent = errors.New("invalid outbox event") // ErrInvalidTable reports that a configured table name is not a safe SQL identifier. ErrInvalidTable = errors.New("invalid outbox table") // ErrStoreNotConfigured reports that the store or pool was not configured. ErrStoreNotConfigured = errors.New("outbox postgres store not configured") )
Functions ¶
This section is empty.
Types ¶
type Options ¶
type Options struct {
Table string
Clock func() time.Time
LeaseOwner string
LeaseDuration time.Duration
RetryDelay time.Duration
MaxRetryDelay time.Duration
MaxAttempts int
}
Options configures the Postgres outbox store.
type Store ¶
type Store struct {
Pool ports.DatabasePool
// contains filtered or unexported fields
}
Store persists and leases outbox events in Postgres.
func New ¶
func New(pool ports.DatabasePool, opts Options) *Store
New creates a Postgres-backed outbox store.
func (*Store) HealthChecker ¶
func (s *Store) HealthChecker() ports.HealthChecker
HealthChecker returns a Postgres outbox dependency health checker.