PostgreSQL Erlang Client Library Epgsql

Epgsql supports asynchronous messages from LISTEN/NOTIFY events

If you use PostgreSQL with Erlang, you’re probably already familiar with the epgsql client library.

Something that slipped my attention was the addition of LISTEN/NOTIFY support for the Erlang PostgreSQL driver, epgsql. This is an incredibly interesting feature that allows you to wake up any client that has executed a LISTEN ; command. Other clients can then notify connected clients this way. Erlang process semantics suit this type of notification – epgsql just sends all NOTIFY events to a listening process.

Asynchronous Messages

PostgreSQL may deliver two types of asynchronous message: “notices” in response
to notice and warning messages generated by the server, and “notifications” which
are generated by the LISTEN/NOTIFY mechanism.

Passing the {async, Pid} option to pgsql:connect will result in these async
messages being sent to the specified process, otherwise they will be dropped.

I’m curious if there are people using this functionality out there. Zotonic, maybe?

Leave a comment