diff --git a/lib/ecto_ttl.ex b/lib/ecto_ttl.ex index 053c69b..b3434db 100644 --- a/lib/ecto_ttl.ex +++ b/lib/ecto_ttl.ex @@ -35,7 +35,7 @@ defmodule Ecto.Ttl do def start(_type, _args) do import Supervisor.Spec - tree = [worker(Ecto.Ttl.Worker, [])] + tree = [worker(Ecto.Ttl.Worker, [[]])] opts = [name: Ecto.Ttl.Sup, strategy: :one_for_one] Supervisor.start_link(tree, opts) end diff --git a/lib/ecto_ttl/worker.ex b/lib/ecto_ttl/worker.ex index b7d5115..23391fe 100644 --- a/lib/ecto_ttl/worker.ex +++ b/lib/ecto_ttl/worker.ex @@ -9,7 +9,9 @@ defmodule Ecto.Ttl.Worker do quote do: Application.get_env(:ecto_ttl, :cleanup_interval, @default_timeout) * 1000 end - def start_link, do: GenServer.start_link(__MODULE__, [], name: __MODULE__) + def start_link(models) when is_list(models), do: GenServer.start_link(__MODULE__, models, name: __MODULE__) + + def init(modules), do: {:ok, modules, cleanup_interval} def handle_call({:set_models, models}, _from, _state), do: {:reply, :ok, models, cleanup_interval} def handle_call({:add_models, models}, _from, state), do: {:reply, :ok, Keyword.merge(state, models), cleanup_interval}