-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Keep track of running idempotent jobs
In order to be able to restart them in case the broker fails.
- Loading branch information
Showing
14 changed files
with
183 additions
and
35 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,3 +8,4 @@ build | |
doc/_build | ||
|
||
.coverage | ||
.pytest_cache |
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 |
---|---|---|
@@ -1,8 +1,12 @@ | ||
local future_jobs = ARGV[1] | ||
local notifications = ARGV[2] | ||
local at_timestamp = ARGV[3] | ||
local job_json = ARGV[4] | ||
local broker_id = ARGV[1] | ||
local future_jobs = ARGV[2] | ||
local notifications = ARGV[3] | ||
local at_timestamp = ARGV[4] | ||
local job_json = ARGV[5] | ||
local job_id = ARGV[6] | ||
local running_jobs_key = ARGV[7] | ||
|
||
redis.call('zadd', future_jobs, at_timestamp, job_json) | ||
redis.call('hdel', running_jobs_key, job_id) | ||
redis.call('publish', notifications, '') | ||
|
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 |
---|---|---|
@@ -1,7 +1,11 @@ | ||
local queue = ARGV[1] | ||
local notifications = ARGV[2] | ||
local job_json = ARGV[3] | ||
local broker_id = ARGV[1] | ||
local queue = ARGV[2] | ||
local notifications = ARGV[3] | ||
local job_json = ARGV[4] | ||
local job_id = ARGV[5] | ||
local running_jobs_key = ARGV[6] | ||
|
||
redis.call('rpush', queue, job_json) | ||
redis.call('hdel', running_jobs_key, job_id) | ||
redis.call('publish', notifications, '') | ||
|
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,22 @@ | ||
local broker_id = ARGV[1] | ||
local queue = ARGV[2] | ||
local running_jobs_key = ARGV[3] | ||
local job_status_running = tonumber(ARGV[4]) | ||
|
||
local job_json = redis.call('lpop', queue) | ||
if not job_json then | ||
return nil | ||
end | ||
|
||
local job = cjson.decode(job_json) | ||
job["status"] = job_status_running | ||
local job_json = cjson.encode(job) | ||
|
||
if job["max_retries"] == 0 then | ||
-- job is not idempotent, there is no use to track | ||
-- if it's running | ||
return job_json | ||
end | ||
|
||
redis.call('hset', running_jobs_key, job["id"], job_json) | ||
return job_json |
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
Oops, something went wrong.