cron_scheduler v0.1.0 CronScheduler

Simple cron-like scheduler that was made for educational purposes

Usage

  Supervisor.init(
    [
      %{
        id: CronScheduler,
        start:
          {CronScheduler, :start_link,
           [
             [
               {"*/3 * * * *", fn -> IO.puts("execute */3 * * * *") end},
               {"* * * * *", fn -> IO.puts("execute * * * * *") end}
             ]
           ]}
      }
    ],
    strategy: :one_for_one
  )

Link to this section Summary

Functions

Returns a specification to start this module under a supervisor.

Link to this section Types

Specs

job() :: {String.t(), module(), String.t()} | {String.t(), function()}

Link to this section Functions

Link to this function

child_spec(arg)

Returns a specification to start this module under a supervisor.

arg is passed as the argument to Task.start_link/1 in the :start field of the spec.

For more information, see the Supervisor module, the Supervisor.child_spec/2 function and the Supervisor.child_spec/0 type.

Specs

loop([job()]) :: no_return()
Link to this function

start_link(jobs)

Specs

start_link([job()]) :: {:ok, pid()}