Documentation
¶
Overview ¶
Package postgres is the fanout.Bus over Postgres LISTEN/NOTIFY, so a deployment whose state is in Postgres needs no second service for fan-out (docs/adr/0008).
Each Bus holds one connection of its own that listens on one channel, whatever the number of topics or subscribers: the topic travels in the payload and the Bus delivers by it. When that connection drops, the Bus reconnects and listens again. Messages sent while it was away are lost, which the port allows: the engine treats every message as a hint and converges without it.
Index ¶
Constants ¶
const Channel = "cartograph_fanout"
Channel is the one NOTIFY channel every replica listens on.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bus ¶
type Bus struct {
// contains filtered or unexported fields
}
Bus is one replica's connection to the fan-out.
func New ¶
New publishes through pool and listens on a connection of its own, configured as the pool's connections are unless ListenOn says otherwise. It returns once that connection is listening, so a message published after New returns reaches this Bus's subscribers.
type Option ¶ added in v2.1.0
Option configures a Bus.
func ListenOn ¶ added in v2.1.0
ListenOn makes the listening connection reach Postgres at url instead of through the pool's settings. LISTEN needs a session of its own, so when the pool goes through a pooler in transaction mode (PgBouncer's usual setting), where LISTEN does not work, url must reach Postgres directly. Publishing (pg_notify) works through any pooler and stays on the pool.