postgres

package
v0.23.1 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package postgres provides an inspectable PostgreSQL job store.

Index

Constants

View Source
const DropSchema = `DROP TABLE IF EXISTS goforge_failed_jobs; DROP TABLE IF EXISTS goforge_jobs;`

DropSchema is intended for isolated integration-test cleanup.

View Source
const Schema = `` /* 2982-byte string literal not displayed */

Schema is the default plain SQL queue schema for application migrations.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(*config) error

Option configures validated PostgreSQL identifiers.

func WithLimits

func WithLimits(maxPayloadBytes, maxErrorBytes int) Option

WithLimits changes defensive encoded payload and diagnostic bounds.

func WithTables

func WithTables(jobsTable, failedTable string) Option

WithTables selects application-owned table names.

type Store

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

Store owns queue operations but not the supplied database handle.

func New

func New(db *sql.DB, options ...Option) (*Store, error)

New creates a PostgreSQL store. The caller retains database ownership.

func (*Store) Ack

func (store *Store) Ack(ctx context.Context, lease job.Lease) (bool, error)

Ack deletes a successfully completed fenced job.

func (*Store) Claim

func (store *Store) Claim(ctx context.Context, request job.ClaimRequest) ([]job.Delivery, error)

Claim atomically leases only known, due jobs and returns after the statement commits.

func (*Store) Enqueue

func (store *Store) Enqueue(ctx context.Context, executor job.Executor, request job.EnqueueRequest) (job.DispatchResult, error)

Enqueue inserts through the explicitly supplied DB or transaction.

func (*Store) Fail

func (store *Store) Fail(ctx context.Context, request job.FailureRequest) (bool, error)

Fail atomically moves a fenced job to terminal failures.

func (*Store) FailExhausted

func (store *Store) FailExhausted(ctx context.Context, queues, names []string, limit int) ([]job.FailedJob, error)

FailExhausted atomically moves expired final-attempt leases to failures.

func (*Store) FindFailed

func (store *Store) FindFailed(ctx context.Context, id job.ID) (job.FailedJobDetail, bool, error)

FindFailed explicitly retrieves one terminal job including its payload.

func (*Store) ForgetFailed

func (store *Store) ForgetFailed(ctx context.Context, id job.ID) (bool, error)

ForgetFailed permanently deletes one terminal failure.

func (*Store) Heartbeat

func (store *Store) Heartbeat(ctx context.Context, lease job.Lease, duration time.Duration) (bool, error)

Heartbeat extends a live fenced lease using the database clock.

func (*Store) ListFailed

func (store *Store) ListFailed(ctx context.Context, limit int) ([]job.FailedJob, error)

ListFailed returns newest payload-free failure summaries first.

func (*Store) Release

func (store *Store) Release(ctx context.Context, lease job.Lease) (bool, error)

Release immediately releases a fenced job without changing its attempt count.

func (*Store) Retry

func (store *Store) Retry(ctx context.Context, request job.RetryRequest) (bool, error)

Retry releases a fenced job at a database-clock-relative delay.

func (*Store) RetryFailed

func (store *Store) RetryFailed(ctx context.Context, id job.ID) (bool, error)

RetryFailed atomically restores one failed job with attempts reset.

Jump to

Keyboard shortcuts

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