-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from paladinsoftware/rework-2.0
Rework 2.0
- Loading branch information
Showing
30 changed files
with
676 additions
and
369 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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
source 'https://rubygems.org' | ||
|
||
gem "sidekiq", "= 6.5.8" | ||
|
||
gemspec path: '../../' |
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,5 @@ | ||
source 'https://rubygems.org' | ||
|
||
gem "sidekiq", "= 7.0.6" | ||
|
||
gemspec path: '../../' |
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,12 @@ | ||
## [2.0.0] - 2023-02-28 | ||
Complete rewrite of the library: | ||
- Instead of iterating through whole schedule set, sidekiq-debouncer will now cache debounce key in redis with a reference to the job. | ||
Thanks to that there is a huge performance boost compared to V1. With 1k jobs in schedule set it's over 100x faster. | ||
The difference is even bigger with larger amount of jobs. | ||
- Debouncing is now handled by Lua script instead of pure ruby so it's process safe. | ||
|
||
Breaking changes: | ||
- Including `Sidekiq::Debouncer` in the workers and using `debounce` method is now deprecated. Use `perform_async` instead. | ||
- Setup requires middlewares to be added in sidekiq configuration. | ||
- `by` attribute is now required | ||
- dropped support for Ruby < 2.7 and Sidekiq < 6.5 |
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,3 +1,3 @@ | ||
source 'https://rubygems.org' | ||
source "https://rubygems.org" | ||
|
||
gemspec |
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,4 @@ | ||
# frozen_string_literal: true | ||
|
||
require "sidekiq" | ||
require "sidekiq/debouncer" |
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,9 @@ | ||
# frozen_string_literal: true | ||
|
||
module Sidekiq | ||
module Debouncer | ||
Error = Class.new(StandardError) | ||
NotSupportedError = Class.new(Error) | ||
MissingArgumentError = Class.new(Error) | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
local set = KEYS[1] | ||
local debounce_key = KEYS[2] | ||
|
||
local job = ARGV[1] | ||
local time = ARGV[2] | ||
local ttl = ARGV[3] | ||
|
||
local existing_debounce = redis.call("GET", debounce_key) | ||
|
||
if existing_debounce then | ||
redis.call("DEL", debounce_key) | ||
-- skip if job wasn't found in schedule set | ||
if redis.call("ZREM", set, existing_debounce) > 0 then | ||
local new_args = cjson.decode(job)['args'][1] | ||
local new_job = cjson.decode(existing_debounce) | ||
table.insert(new_job['args'], new_args) | ||
job = cjson.encode(new_job) | ||
end | ||
end | ||
|
||
redis.call("SET", debounce_key, job, "EX", ttl) | ||
redis.call("ZADD", set, time, job) |
Oops, something went wrong.