Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing reschedule when using a non default queue #679

Merged
merged 3 commits into from
Feb 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/sidekiq_unique_jobs/on_conflict/reschedule.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def initialize(item, redis_pool = nil)
# This will mess up sidekiq stats because a new job is created
def call
if sidekiq_worker_class?
if worker_class.perform_in(5, *item[ARGS])
if worker_class.set(queue: item["queue"].to_sym).perform_in(5, *item[ARGS])
reflect(:rescheduled, item)
else
reflect(:reschedule_failed, item)
Expand Down
9 changes: 8 additions & 1 deletion spec/sidekiq_unique_jobs/on_conflict/reschedule_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
let(:item) do
{ "class" => worker_class,
"lock_digest" => lock_digest,
"args" => [1, 2] }
"args" => [1, 2],
"queue" => "default" }
end

describe "#call" do
Expand All @@ -19,6 +20,9 @@

context "when pushed" do
before do
allow(UniqueJobOnConflictReschedule).to receive(:set)
.with(queue: :default)
.and_return(UniqueJobOnConflictReschedule)
allow(UniqueJobOnConflictReschedule).to receive(:perform_in).and_call_original
end

Expand All @@ -39,6 +43,9 @@

context "when push fails" do
before do
allow(UniqueJobOnConflictReschedule).to receive(:set)
.with(queue: :default)
.and_return(UniqueJobOnConflictReschedule)
allow(UniqueJobOnConflictReschedule).to receive(:perform_in).and_return(nil)
end

Expand Down