pgx

package
v0.10.0 Latest Latest
Warning

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

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

Documentation

Overview

Package pgx provides a durable queue.Service backed by PostgreSQL using jackc/pgx/v5.

Workers wake on LISTEN/NOTIFY (channel name = formatted topic) and fall back to polling at WithPollInterval. The NOTIFY payload is intentionally empty — the channel name alone signals "wake up and re-poll", which sidesteps the 8KB Postgres notification payload limit and avoids quoting concerns.

The listener uses one dedicated connection acquired from the pool. If that connection drops, notifications are lost until the next subscriber starts; the polling fallback ensures jobs are eventually picked up. Auto-reconnect is intentionally not implemented — match pubsub/pgx's behavior and document the limitation.

Index

Constants

This section is empty.

Variables

View Source
var Schema string

Functions

func Apply

func Apply(ctx context.Context, pool *pgxpool.Pool) error

Apply executes the embedded schema against pool. Idempotent.

Types

type Service

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

Service is the pgx queue implementation.

func New

func New(pool *pgxpool.Pool, opts ...queue.QueueOption) *Service

New constructs a pgx queue service.

func (*Service) Close

func (s *Service) Close(_ context.Context) error

Close shuts down consumers, the listener, and releases the listener conn.

func (*Service) Enqueue

func (s *Service) Enqueue(ctx context.Context, topicName string, payload []byte, opts ...queue.EnqueueOption) error

Enqueue inserts a row and fires NOTIFY.

func (*Service) Subscribe

func (s *Service) Subscribe(ctx context.Context, topicName string, h queue.Handler, opts ...queue.SubscribeOption) (queue.Consumer, error)

Subscribe spawns a worker pool and ensures the LISTEN connection is up.

Jump to

Keyboard shortcuts

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