Lazy connections
sonic182 opened this issue · comments
Johanderson Mogollon commented
db_connection supports lazy pools?
I mean, create connections by demand and close them if idle
José Valim commented
That's not a decision imposed by db_connection. You can async/lazily connect, but you implement it in your callbacks.
Johanderson Mogollon commented
Is there any example of that?
it is complicated to specify a custom pool module for opts in Repo, it is heavy sticket to the one implemented here in db_connection and the Holder
José Valim commented
Look at Postgrex. It attempts to connect on init, but if it fails, it does so asynchronously. The same principle could be used for laziness. It is a matter of not doing it on init but when the callbacks are invoked.