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 ¶
New constructs a Listener for the supplied DSN and channel. It does not connect until Start is called. Its connection reports on the pg_listen_* series as "listen_" + channel; the channels are the platform's own constants, which bounds the label.
func (*Listener) Start ¶
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).
pq's Listen waits until a connection exists, so against a database that never answers Start does not return on its own. Stop ends that wait: Start then returns net.ErrClosed, which is also what a Start after Stop returns.
func (*Listener) Stop ¶
func (l *Listener) Stop()
Stop closes the LISTEN connection, ends a Start still waiting for one, and waits for the receive goroutine. No connection event is logged after Stop returns. pq's own reconnect goroutine may outlive it by one backoff sleep before it sees the close and exits.