Documentation
¶
Overview ¶
Package pgnotify runs one shared PostgreSQL LISTEN connection and dispatches notifications to per-channel reload functions. It owns the pinned connection, dispatch, reconnect, and health; it knows nothing about what any cache holds.
Index ¶
Constants ¶
const AppName = "memory-config-listener"
AppName tags the listener's backend in pg_stat_activity so operators can find (and tests can terminate) exactly this connection.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Listener ¶
type Listener struct {
// contains filtered or unexported fields
}
Listener holds the dedicated LISTEN connection and its channel registrations.
func (*Listener) Healthy ¶
Healthy reports whether the listener currently holds a live listening connection.
func (*Listener) Register ¶
func (l *Listener) Register(channel string, reload ReloadFunc)
Register binds a reload function to a channel. Call before Start; the set is read when the connection is (re)established.
type Option ¶
type Option func(*Listener)
Option tunes a Listener at construction.
func WithBackoff ¶
WithBackoff sets the reconnect backoff ramp (base doubles up to max).
type ReloadFunc ¶
ReloadFunc reloads a cache from the database. It MUST be idempotent: the listener calls it on every reconnect and a replica may get its own notification, so a redundant reload has to be a no-op.