Get the latest tech news
The notifier pattern for applications that use Postgres
Maximizing Postgres connection econonmy by using a single connection per program to receive and distribute all listen/notify notifications.
Especially for languages like Go that make a in-process concurrency easy and cheap, the notifier reduces listen/notify connection overhead to practically nil. The inner closure calls into WaitForNotification, but has a default context timeout of 30 seconds that automatically cycles the function periodically. Given there’s now a single master connection that’s handling all notifications for a program, it’s fairly critical that its health be monitored, and the notifier reacts appropriately.
Or read this on Hacker News