elixir-ecto / db_connection

Database connection behaviour

Home Page:http://hexdocs.pm/db_connection/DBConnection.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Should `notify_connection_listeners` just be `telemetry` events?

isaacsanders opened this issue · comments

Right now there is system that couples the disconnects and connects to the specific implementation of connection listeners, but I think that the current approach for this soft of "observer" pattern would be more often done as a telemetry event.

The main reason is that we don't want to allow custom code to run from connection processes, so a subscription style seems more appropriate. You can always emit telemetry from a listener though!

Also note that disconnected is not guaranteed to be invoked, I pushed some docs making it clearer. So you need a subscription+monitor depending on what you want to achieve with telemetry.