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

Only unlock not delete #285

Merged
merged 4 commits into from
Jun 30, 2018
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
1 change: 0 additions & 1 deletion lib/sidekiq_unique_jobs/lock/base_lock.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ def prepare_item(item)
def unlock_and_callback(callback)
return notify_about_manual_unlock unless operative
unlock
delete

return notify_about_manual_unlock if locked?
callback_safely(callback)
Expand Down
2 changes: 0 additions & 2 deletions lib/sidekiq_unique_jobs/unique_args.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
module SidekiqUniqueJobs
# This class exists to be testable and the entire api should be considered private
class UniqueArgs
CLASS_NAME = 'SidekiqUniqueJobs::UniqueArgs'

include SidekiqUniqueJobs::Logging
include SidekiqUniqueJobs::SidekiqWorkerMethods

Expand Down
6 changes: 5 additions & 1 deletion spec/examples/my_unique_job_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,18 @@
let(:args) { %w[one two] }
end

describe 'client middleware' do
describe 'client middleware', redis: :redis do
context 'when job is delayed' do
before { described_class.perform_in(3600, 1, 2) }

it 'rejects new scheduled jobs' do
expect(1).to be_enqueued_in('customqueue')
described_class.perform_in(3600, 1, 2)
described_class.perform_in(3600, 1, 2)
described_class.perform_in(3600, 1, 2)
expect(1).to be_enqueued_in('customqueue')
expect(1).to be_enqueued_in('schedule')
expect(zcard('schedule')).to eq(1)
expect(1).to be_scheduled_at(Time.now.to_f + 2 * 3600)
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
it 'rejects nested subsequent jobs with the same arguments' do
expect(SimpleWorker.perform_async(1)).not_to eq(nil)
expect(SimpleWorker.perform_async(1)).to eq(nil)
expect(SimpleWorker.perform_in(60, 1)).to eq(nil)
expect(SimpleWorker.perform_in(60, 1)).to eq(nil)
expect(SimpleWorker.perform_in(60, 1)).to eq(nil)
expect(zcard('schedule')).to eq(0)
expect(SpawnSimpleWorker.perform_async(1)).not_to eq(nil)

expect(queue_count('default')).to eq(1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@
version_key,
available_run_key,
available_key,
exists_run_key,
version_run_key,
])
end
end
Expand Down
8 changes: 4 additions & 4 deletions spec/support/sidekiq_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ def zcard(queue)
redis { |conn| conn.zcard(queue) }
end

def zcount(queue, time)
redis { |conn| conn.zcount(queue, -1, time) }
def zcount(queue, min = '-inf', max = '+inf')
redis { |conn| conn.zcount(queue, min, max) }
end

def hexists(hash, key)
Expand All @@ -39,8 +39,8 @@ def schedule_count
zcard('schedule')
end

def schedule_count_at(time = Time.now.to_f + 2 * 60)
zcount('schedule', time)
def schedule_count_at(max = Time.now.to_f + 2 * 60)
zcount('schedule', '-inf', max)
end

def queue_count(queue)
Expand Down