sqlitex
sqlitex copied to clipboard
Support shutdown schedule for the Sqlitex.Server process after inactivity
Having a long running Sqlitex.Server process is awesome. What if I have N number of sqlite files in my project, and I want to start a process per file. Since I will have N processes running, I will want any process that has not been queried for a certain time, say 10 minutes, to be automatically shutdown.
Something like:
def init({state, timeout}) do
Process.send_after(self(), :shutdown, timeout)
{:ok, []}
end
def handle_info(:shutdown, _state) do
exit(:normal)
{:noreply, []}
end
Thanks
this could be implemented by doing something like:
def init({state, timeout}) do
{:ok, [], timeout}
end
def handle_info(:timeout, _state) do
{:stop, :normal, state}
end
I'll have to think about the implications of this in the context of the ecto adapter