Phoenix 1.4 Chat Server Series Overview Managing fault tolerance in Elixir with supervision trees

Even intervals to schedule your task

Created a library Every to use with periodic tasks when you need to schedule you task at even intervals, for example every 5 minutes, every minute, every hour, every 2 hours, every day and so on. And can be used with Process.send_after/3.

# Lets say we want to trigger our task every 5 minutes and current time is 12:02
# so next call will be at 12:05, 12:10 ... 12:55 ...
Process.send_after(self(), :work, Every.minutes(5))

# If we want to trigger every minute
Process.send_after(self(), :work, Every.minute())

# If we want to trigger every hour
Process.send_after(self(), :work, Every.hour())

# If we want to trigger every 2 hours
Process.send_after(self(), :work, Every.hours(2))

# If we want to trigger every day
Process.send_after(self(), :work, Every.day())