Skip to content

Commit

Permalink
Removed commented code and fixed a typo.
Browse files Browse the repository at this point in the history
  • Loading branch information
pyatkov committed Mar 5, 2018
1 parent 26a10a9 commit a6bc03a
Showing 1 changed file with 8 additions and 41 deletions.
49 changes: 8 additions & 41 deletions lib/quantum/storage/persistent_ets.ex
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ defmodule Quantum.Storage.PersistentEts do

#Callbacks

defp __setver__, do: __MODULE__
defp __server__, do: __MODULE__

def init(_) do
{:ok, %__MODULE__{schedulers: %{}}}
Expand Down Expand Up @@ -76,9 +76,7 @@ defmodule Quantum.Storage.PersistentEts do
end
# Helpers
defp create_scheduler_module_atom(scheduler_module) do
# Try module name without any transformation.
scheduler_module
# "#{scheduler_module}" |> String.downcase |> String.to_atom |> Atom.to_string |> String.splitter(".") |> Enum.reduce(nil, fn x, _ -> x end) |> String.to_atom
end

defp job_key(job_name) do
Expand Down Expand Up @@ -174,55 +172,24 @@ defmodule Quantum.Storage.PersistentEts do
@behaviour Quantum.Storage.Adapter

def jobs(scheduler_module) do
__setver__ |> GenServer.call({:jobs, scheduler_module})
# table = get_ets_by_scheduler(scheduler_module)
# case :ets.match(table, {:job, '$1'}) do
# [] -> :not_applicable
# [_h|_t] = jobs -> jobs
# end
__server__ |> GenServer.call({:jobs, scheduler_module})
end
def add_job(scheduler_module, job) do
__setver__ |> GenServer.call({:add_job, scheduler_module, job})
# table = get_ets_by_scheduler(scheduler_module)
# :ets.insert(table, {job_key(job.name), job})
# :ok
__server__ |> GenServer.call({:add_job, scheduler_module, job})
end
def delete_job(scheduler_module, job_name) do
__setver__ |> GenServer.call({:delete_job, scheduler_module, job_name})
# table = get_ets_by_scheduler(scheduler_module)
# :ets.delete(table, job_key(job_name))
# :ok
__server__ |> GenServer.call({:delete_job, scheduler_module, job_name})
end
def update_job_state(scheduler_module, job_name, state) do
__setver__ |> GenServer.call({:update_job_state, scheduler_module, job_name, state})
# table = get_ets_by_scheduler(scheduler_module)
# job =
# case :ets.lookup(table, {:job, job_name}) do
# [] -> raise "Job #{job_name} does not exist in the storage" # TODO: should we raise here or should we handle the situation with a return value of a special kind?
# [j|_t] -> j
# end
# upd_job = %{job|state: state}
# :ets.update_element(table, job_key(job_name), {1, upd_job})
# :ok
__server__ |> GenServer.call({:update_job_state, scheduler_module, job_name, state})
end
def last_execution_date(scheduler_module) do
__setver__ |> GenServer.call({:last_execution_date, scheduler_module})
# table = get_ets_by_scheduler(scheduler_module)
# case :ets.lookup(table, :last_execution_date) do
# [] -> :unknown
# [date|_t] -> date
# end
__server__ |> GenServer.call({:last_execution_date, scheduler_module})
end
def update_last_execution_date(scheduler_module, last_execution_date) do
__setver__ |> GenServer.call({:update_last_execution_date, scheduler_module, last_execution_date})
# table = get_ets_by_scheduler(scheduler_module)
# :ets.insert(table, {:last_execution_date, last_execution_date})
# :ok
__server__ |> GenServer.call({:update_last_execution_date, scheduler_module, last_execution_date})
end
def purge(scheduler_module) do
__setver__ |> GenServer.call({:purge, scheduler_module})
# table = get_ets_by_scheduler(scheduler_module)
# :ets.delete_all_objects(table)
# :ok
__server__ |> GenServer.call({:purge, scheduler_module})
end
end

0 comments on commit a6bc03a

Please sign in to comment.