Help us shape the future of Go! Take the 2026 Go Developer Survey

postgres

package
v0.106.2 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MessageQueueImplOpt

type MessageQueueImplOpt func(*MessageQueueImplOpts)

func WithLogger

func WithLogger(l *zerolog.Logger) MessageQueueImplOpt

func WithQos

func WithQos(qos int) MessageQueueImplOpt

type MessageQueueImplOpts

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

type PostgresMessageQueue

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

func (*PostgresMessageQueue) Clone

func (p *PostgresMessageQueue) Clone() (func() error, msgqueue.MessageQueue, error)

func (*PostgresMessageQueue) IsReady

func (p *PostgresMessageQueue) IsReady() bool

func (*PostgresMessageQueue) SendMessage added in v0.74.3

func (p *PostgresMessageQueue) SendMessage(ctx context.Context, queue msgqueue.Queue, task *msgqueue.Message) error

func (*PostgresMessageQueue) SetQOS

func (p *PostgresMessageQueue) SetQOS(prefetchCount int)

func (*PostgresMessageQueue) Subscribe

func (p *PostgresMessageQueue) Subscribe(queue msgqueue.Queue, preAck msgqueue.MsgHandler, postAck msgqueue.MsgHandler) (func() error, error)

type PubSub added in v0.98.9

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

PubSub implements msgqueue.PubSub in Postgres, using LISTEN/NOTIFY for messages less than 8KB and the "MessageQueueItem" table for messages greater than 8KB.

func NewPubSub added in v0.98.9

func NewPubSub(repo v1.MessageQueueRepository, fs ...PubSubOpt) (func() error, *PubSub, error)

NewPubSub creates a new Postgres-backed PubSub over the given message queue repository.

The repo must be built on a dedicated pool from the direct (non-pgbouncer) database URL — never the shared repository pool or the pgbouncer URL. Pub can be called from within durable-write paths (so sharing pools is a deadlock risk), and LISTEN does not survive transaction pooling.

func (*PubSub) IsReady added in v0.98.9

func (p *PubSub) IsReady() bool

IsReady reports whether the database backing the pub/sub is reachable. Note that this is informational: it is deliberately not wired into the health probes, since a degraded pub/sub shouldn't fail liveness or readiness.

func (*PubSub) Pub added in v0.98.9

func (p *PubSub) Pub(ctx context.Context, topic msgqueue.Topic, msg *msgqueue.Message) error

Pub publishes a message to the topic via NOTIFY. Payloads whose wrapped message exceeds pg_notify's 8KB limit fall back to a short-lived message queue row (see MessageQueueRepository.Notify), which subscribers drain with a ~1s poll — task-stream-event payloads routinely exceed 8KB and stream delivery must not regress.

func (*PubSub) Sub added in v0.98.9

func (p *PubSub) Sub(topic msgqueue.Topic, handler msgqueue.MsgHandler) (func() error, error)

Sub subscribes to a topic. Inline NOTIFY payloads are handled directly; non-JSON notifications and a 1s ticker wake a poll that drains >8KB fallback rows. Delivery is at-most-once: handler errors are logged, never redelivered.

Fanout divergence: inline NOTIFY payloads reach every subscriber of the topic, but each >8KB fallback row is read and acked by exactly one subscriber, unlike the rabbitmq fanout, which delivers every message to every subscriber.

type PubSubOpt added in v0.98.9

type PubSubOpt func(*PubSubOpts)

func WithPubSubLogger added in v0.98.9

func WithPubSubLogger(l *zerolog.Logger) PubSubOpt

func WithPubSubPool added in v0.98.9

func WithPubSubPool(pool *pgxpool.Pool) PubSubOpt

WithPubSubPool provides the pool backing the repository so IsReady can ping the database; without it, IsReady always reports true.

type PubSubOpts added in v0.98.9

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

Jump to

Keyboard shortcuts

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