I want to create a quantum elixir job and control the time it is executed. I started with this:
Quantum.Job.new(task: fn -> IO.puts "Hello!" end)
but it throws this error:
** (KeyError) key :run_strategy not found in: [task: #Function<20.99386804/0 in :erl_eval.expr/5>]
(elixir) lib/keyword.ex:371: Keyword.fetch!/2
(quantum) lib/quantum/job.ex:58: Quantum.Job.new/1
I really don't understand the run_strategy setting and it's possible values.
Does somebody knows how to create a quantum job using the struct of Quantum.Job.new or something similar?
NOTE: the cron is already working using this:
config :sopitas, Sopitas.Scheduler,
jobs: [
# Every minute
{"@minutely", {Sopitas.Admin.FixtureController, :update_cron, []}},
{"@minutely", {Sopitas.Admin.StandingController, :update_cron, []}},
{"@daily", {Sopitas.Admin.LeagueController, :update_cron, []}},
]
but the point is to change the time the cron is executed, that's why I decided to create it using Quantum.Job.new
The very first sentence in the
Quantum.Jobdoc says:The
Quantum.Jobitself is astructwith three mandatory keys:If you are still positive you want to violate their guidelines, you should pass these three keywords, like:
I would suggest you use one of the examples provided here, though.