elixir-ecto / db_connection

Database connection behaviour
http://hexdocs.pm/db_connection/DBConnection.html
306 stars 113 forks source link

Add after_connect feature to db_connection #2

Closed josevalim closed 8 years ago

josevalim commented 8 years ago

We should do this here or in Ecto. Keep in mind we don't need to keep Ecto API, we could for example ask a tuple of {Mod, fun, args} to be given on configuration.

fishcakez commented 8 years ago

I think we could use Task.Supervisor.start_child to start a task that reuses DBConnection.run/3 by creating a fake DBConnection.Task pool module. That should allow Ecto to use its query API on on_connect, instead of the drivers.

I think its ok to accept {mod, fun, args} | ((DBConnection.t) -> any) like a Task. If you want something different let me know.

josevalim commented 8 years ago

@fishcakez honestly, I don't care about folks using ecto API in after_connect. If you need to use it, it will be mostly a db specific command anyway, so you may as well go through the driver. So feel free to do the simplest thing :)