Skip to content
Run tasks in a an interval basis
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
config
lib
test
.credo.exs
.formatter.exs
.gitignore
.travis.yml
CHANGELOG
CODE_OF_CONDUCT.md
CONTRIBUTING.md
ISSUE_TEMPLATE.md
LICENSE.txt
README.md
mix.exs
mix.lock

README.md

ExSchedule

Build Status Package Version Coverage Status

This project provides a way to run tasks in an interval basis.

Documentation

Installation

The package can be installed by adding ex_schedule to your list of dependencies in mix.exs:

def deps do
  [
    {:ex_schedule, "~> 0.1"}
  ]
end

Getting Started

After installation you can use the ExSchedule module and define the scheduled tasks using the schedule macro.

Usage

Define a schedule module with recurring tasks:

defmodule YourApp.Schedules.Developer do
  use ExSchedule

  schedule every: {6, :hours} do
    Developer.eat(:pizza)
  end

  schedule every: :hour, first_in: {20, :minutes} do
    Developer.drink(:coffee)
  end
end

Add the module to your supervision tree:

defmodule YourApp.Application do
  use Application

  import Supervisor.Spec

  def start(_type, _args) do
    opts = [strategy: :one_for_one, name: YourApp.Supervisor]
    children = [supervisor(YourApp.Schedules.Developer, [[name: :developer_schedule]])]

    Supervisor.start_link(children, opts)
  end
end

Authors

License

Copyright (c) 2018 Quiqup LTD, MIT License. See LICENSE.txt for further details.

You can’t perform that action at this time.