Timelier is a cron style scheduling application for Elixir. It will match a list of time 'patterns' against the current time and start any tasks associated with each matching pattern.
- Add
timelier
to your list of dependencies inmix.exs
:
def deps do
[{:timelier, "~> 0.9.2"}]
end
- To ensure
timelier
can successfully start tasks defined in your application (or its dependencies), add it as an included application:
def application do
[included_applications: [:timelier]]
end
and append it's root supervisor to the list of children that your own top-level supervisor starts, e.g.
def start(_type, _args) do
import Supervisor.Spec, warn: false
# Define workers and child supervisors to be supervised
children = [
worker(YourApp.YourWorker, []),
# Other children in your supervision tree...
supervisor(Timelier.Supervisor, []) # Add timelier's top-level supervisor
]
opts = [strategy: :one_for_one, name: YourApp.Supervisor]
Supervisor.start_link(children, opts)
end
There are three configuration variables that may be specified in the :timelier
application:
crontab
: The list of crontab entries - see below for a discussion of the format. If not specified, defaults to the empty list.timezone
: Either:local
or:utc
. This determines how the current time is matched against the crontab entries. If not specified, defaults to:local
provider
: Allows the source of crontab configuration to be overridden. See the hex docs for more information.
Each entry in the crontab list is a 2-tuple of {pattern, task}
.
- The pattern is a 5-tuple of the form
{minute, hour, day, day-of-week, month}
. Both wildcards and alternates may be specified for each entry. See the hex docs for more detail. - The task is a 3-tuple of {module, function, args} as would be passed to
Kernel.apply/3
.