sqlitex icon indicating copy to clipboard operation
sqlitex copied to clipboard

Support shutdown schedule for the Sqlitex.Server process after inactivity

Open vinaya-procore opened this issue 6 years ago • 1 comments

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

vinaya-procore avatar Oct 30 '19 21:10 vinaya-procore

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

ConnorRigby avatar Oct 31 '19 18:10 ConnorRigby