-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Job retries with exponential backoff
* Configure job retries in Config.mix * Move failed jobs only after they have failed
- Loading branch information
Showing
9 changed files
with
141 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
defmodule Exq.Redis.JobStat do | ||
require Logger | ||
use Timex | ||
|
||
alias Exq.Redis.Connection | ||
alias Exq.Redis.JobQueue | ||
alias Exq.Support.Json | ||
alias Exq.Support.Job | ||
|
||
def record_processed(redis, namespace, _job) do | ||
time = DateFormat.format!(Date.universal, "%Y-%m-%d %T %z", :strftime) | ||
date = DateFormat.format!(Date.universal, "%Y-%m-%d", :strftime) | ||
|
||
[{:ok, count}, {:ok, _,}, {:ok, _}, {:ok, _}] = :eredis.qp(redis,[ | ||
["INCR", JobQueue.full_key(namespace, "stat:processed")], | ||
["INCR", JobQueue.full_key(namespace, "stat:processed_rt:#{time}")], | ||
["EXPIRE", JobQueue.full_key(namespace, "stat:processed_rt:#{time}"), 120], | ||
["INCR", JobQueue.full_key(namespace, "stat:processed:#{date}")] | ||
]) | ||
{:ok, count} | ||
end | ||
|
||
def record_failure(redis, namespace, error, _job) do | ||
time = DateFormat.format!(Date.universal, "%Y-%m-%d %T %z", :strftime) | ||
date = DateFormat.format!(Date.universal, "%Y-%m-%d", :strftime) | ||
|
||
[{:ok, count}, {:ok, _,}, {:ok, _}, {:ok, _}] = :eredis.qp(redis, [ | ||
["INCR", JobQueue.full_key(namespace, "stat:failed")], | ||
["INCR", JobQueue.full_key(namespace, "stat:failed_rt:#{time}")], | ||
["EXPIRE", JobQueue.full_key(namespace, "stat:failed_rt:#{time}"), 120], | ||
["INCR", JobQueue.full_key(namespace, "stat:failed:#{date}")] | ||
]) | ||
{:ok, count} | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# https://groups.google.com/forum/#!topic/elixir-lang-talk/drTvms2hcwE | ||
defmodule Exq.Support.Randomize do | ||
@on_load :reseed_generator | ||
|
||
def reseed_generator do | ||
:random.seed(:os.timestamp()) | ||
:ok | ||
end | ||
|
||
def random(number) do | ||
:random.uniform(number) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters