I have an application which I’m using Mariaex
to query a MySQL db, but I’m not using Ecto. I’m curious what the proper way is to handle connection/instances of Mariaex for a long-running application? Under the hood, Mariaex uses DBConnection
to create the connection and do all the connection pooling stuff, but I’m unsure if I’m supposed to just start one instance of Mariaex (via start_link
) and hold on to that pid for the duration of the application (ultimately I’m sure I’d use a supervisor), or if I should be calling Mariaex.start_link/1
each time I want to perform a new query? If the latter, do I manually stop the pid returned by Mariaex.start_link/1
when the query has completed? Does DBConnection handle shutting it down?
I’ve looked through Mariaex, DBConnection, and Ecto’s codebases to try to understand how it’s handled in Ecto, but there’s a sufficient amount of abstraction and indirection that I haven’t really been able to tell how Ecto handles this.
I’d appreciate any advice anyone could provide on this.
** UPDATE **
Sorry, I guess I shouldn’t have posted this on a day when I was loaded up on cold medicine. I now see that I had forgotten to set the pool to DBConnection.Poolboy
or DBConnection.Sojourn
, (though in observer
there was a DBConnection.Sojourn.Supervisor
started, so I naively assumed sojourn was being used by default), and had confused myself about the connection behavior.