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 responseto notice and warning messages generated by the server, and “notifications” whichare generated by the LISTEN/NOTIFY mechanism.

Passing the {async, Pid} option to pgsql:connect will result in these asyncmessages 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?