Closed slashdotdash closed 3 years ago
@slashdotdash just one minor comment, everything else looks excellent. The biggest question now is if this is enough to solve your original problems. :)
The biggest question now is if this is enough to solve your original problems. :)
Yes, I think so. My goal was to allow a connection to be monitored so when it is connected or disconnected I can handle these state changes elsewhere. It was possible to use the after_connect
callback to support the connections, but not disconnects. The connection listeners allows both.
I will look at fixing the failing CI tests on Erlang 19.3 and 20.3 versions.
:green_heart: :blue_heart: :purple_heart: :yellow_heart: :heart:
@josevalim I did some testing of the new :connection_listeners
option and it worked as I had hoped for when simulating a flaky database connection with Postgrex by starting/stopping the Postgres server.
{:connected, #PID<0.297.0>} {:disconnected, #PID<0.297.0>} {:connected, #PID<0.298.0>}
The
:connection_listeners
option allows one or more processes to be notified whenever a connection is connected or disconnected. A listener may be a remote or local PID, a local port, a locally registered name, or a tuple in the form of{registered_name, node}
for a registered name at another node.Each listener process may receive the following messages where
pid
identifies the connection process:{:connected, pid}
{:disconnected, pid}
Related to #227.
@josevalim Does this follow what you were initally suggesting?