pglisten

package
v1.131.0 Latest Latest
Warning

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

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

Documentation

Overview

Package pglisten is the LISTEN half of a PostgreSQL LISTEN/NOTIFY wakeup: one goroutine holding a dedicated connection that wakes registered workers whenever a producer fires NOTIFY on the channel it watches.

Every durable queue in this codebase is a table a worker polls, and every one of them wants the same thing on top of the poll: a producer's write should wake a worker now rather than at the next tick. The mechanism is identical across queues — only the channel name differs — so it lives here once, with the channel as a parameter, rather than being copied per queue. The notification delivery queue and the managed-script run queue both use it.

A listener is an optimization, never a correctness requirement: every worker it wakes also polls, so a failed or absent listener degrades latency and nothing else.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Listener

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

Listener wakes its notifiers on every NOTIFY received on one channel.

func New

func New(dsn, channel string, notifiers ...Notifier) *Listener

New constructs a Listener for the supplied DSN and channel. It does not connect until Start is called.

func (*Listener) Start

func (l *Listener) Start(_ context.Context) error

Start opens the LISTEN connection and spawns the receive goroutine. An error means the woken workers degrade to their poll interval; the caller decides whether that is fatal (it should not be).

func (*Listener) Stop

func (l *Listener) Stop()

Stop closes the LISTEN connection and waits for the receive goroutine.

type Notifier

type Notifier interface {
	Notify()
}

Notifier is the worker hook a listener fires on every received NOTIFY. A worker's Notify method implements it; the one-method interface keeps this package independent of the workers it wakes and keeps it testable with a fake.

Jump to

Keyboard shortcuts

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