   require Logger
 
   alias Geolix.Database.Supervisor, as: DatabaseSupervisor
+
+  @ets_state_name :geolix_database_loader
+  @ets_state_opts [:named_table, :protected, :set, read_concurrency: true]
 
   # GenServer lifecycle
 

    db
  end

  defp register_state(:ok, db), do: Map.put(db, :state, :loaded)
  defp register_state({:error, _} = err, db), do: Map.put(db, :state, err)

  defp unload_database(nil), do: :ok

  defp unload_database(%{adapter: adapter} = database) do
    case function_exported?(adapter, :unload_database, 1) do
      true -> adapter.unload_database(database)
      false -> :ok
    end
  end
end

  defp load_error_message({:config, :unknown_adapter}), do: "unknown adapter configuration"
  defp load_error_message(reason), do: inspect(reason)

  defp lookup_database(which) do
    case :ets.lookup(@ets_state_name, which) do
      [{^which, db}] -> db
      _ -> nil
    end
  end

  defp maybe_log_error(%{state: :loaded} = db), do: db

  defp maybe_log_error(%{state: {:error, reason}} = db) do
