How to use Quantum?

Am new to Elixir and i need help how to schedule a task…

defmodule PluralsightTweet.Scheduler do
  def schedule_file(schedule, file) do
    Quantum.add_job(schedule, fn -> IO.puts PluralsightTweet.FileReader.get_strings_to_tweet(file) end)
  end
end

this is the error am getting:

Quantum.add_job(“* * * * * * “, fn-> IO.puts “test” end)
** (UndefinedFunctionError) function Quantum.add_job/2 is undefined or private
(quantum) Quantum.add_job(”
* * * * * *”, #Function<20.99386804/0 in :erl_eval.expr/5>)

That’s not how you must use Quantum, follow their documentation on: https://hexdocs.pm/quantum/readme.htm

More details:

  • Quantum.add_job/2 is not a function, maybe what you mean is Quantum.Scheduler.add_job/2
  • Quantum.Scheduler.add_job/2 is not a function also, and yes a callback that should be defined by the modules that use @behaviour Quantum.Scheduler

My impression is that you may be confusing what the lib quantum really is. It’s not a job scheduler like, for example, sidekiq, what it does is something like what the command line tool cron does, scheduling recurrent executions.

By scheduling you mean running it once in the future or recurrently?