sidekiq-unique-jobs 4.0.15 → 4.0.16

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of sidekiq-unique-jobs might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fae23c1545dd81bcf054b01f5d7aa26cb4585e18
4
- data.tar.gz: 13aad39ea7821ec2886992ed873e06545fac4a86
3
+ metadata.gz: aa74d419e8964813243a427ec860730ac44dfe36
4
+ data.tar.gz: e4e1850f812e286a59e4de00c9ea2f6b4ff6d392
5
5
  SHA512:
6
- metadata.gz: adcee484a254153c691743dfd6576b81207ef824acf37c6572afb8229ed9fdb82571f7677b5be6e32f41c8d93c41c5ea6077967b2ff0a0fa16be7b420afa5df4
7
- data.tar.gz: e9be8f0c54505d544ad63b3eb85c16ed4f6e69894683db4f70f58138d0b49445e263904479259b5d2a897c4cdc44ef7b2d3d7046b7bba0553255edb042c9e719
6
+ metadata.gz: f6d6e3e9c95acfc333bb8d697121d53a2a8208fbca08ce9790c5457f08f6680c7469d7493cdc5eeb2bf49046c4094ebf23cb5a1449e63793169a9ad3d5d9bffc
7
+ data.tar.gz: 810c75a9aafd58ef30cb4a99568ac9a24d49062fe69ef7a11512e9c261d5e2e8af730a109c4213f083024dcc9ae10d0f6d9c56ae41c80a7ed68f41df8b34df40
@@ -0,0 +1,22 @@
1
+ engines:
2
+ bundler-audit:
3
+ enabled: true
4
+ fixme:
5
+ enabled: true
6
+ duplication:
7
+ enabled: true
8
+ rubocop:
9
+ enabled: true
10
+ golint:
11
+ enabled: true
12
+ ratings:
13
+ paths:
14
+ - lib/**
15
+ - bin/**
16
+ - "**.rb"
17
+ exclude_paths:
18
+ - spec/
19
+ - gemfiles/
20
+ - rails_example/
21
+ - redis/
22
+ - tmp/
@@ -1,6 +1,10 @@
1
1
  sudo: false
2
2
  language: ruby
3
3
  cache: bundler
4
+ before_install:
5
+ - rvm get head
6
+ - gem update --system
7
+ - gem install bundler
4
8
  services:
5
9
  - redis-server
6
10
  script:
@@ -1,3 +1,14 @@
1
+ ## v4.0.16
2
+
3
+ - Allow run & queue lock timeout (expiration) to be different [#164](https://github.com/mhenrixon/sidekiq-unique-jobs/pull/164)
4
+ - Fix a bug with loading sidekiq test overrides ([#167](https://github.com/mhenrixon/sidekiq-unique-jobs/issues/167)
5
+
6
+ ## v4.0.15
7
+
8
+ - Close [#156](https://github.com/mhenrixon/sidekiq-unique-jobs/pull/156)
9
+ - Close [#158](https://github.com/mhenrixon/sidekiq-unique-jobs/pull/158)
10
+ - Style fixes and some minor adjustments to the console/cmd line app
11
+
1
12
  ## v4.0.13
2
13
 
3
14
  - Allow deleting locks by jid
@@ -5,19 +16,19 @@
5
16
  ## v4.0.12
6
17
 
7
18
  - Allow jobs to be pushed to processing
8
- - Close #150
9
- - Close #151
10
- - Close #146
11
- - Close #136
12
- - Close #133
19
+ - Close [#150](https://github.com/mhenrixon/sidekiq-unique-jobs/pull/150)
20
+ - Close [#151](https://github.com/mhenrixon/sidekiq-unique-jobs/pull/151)
21
+ - Close [#146](https://github.com/mhenrixon/sidekiq-unique-jobs/pull/146)
22
+ - Close [#136](https://github.com/mhenrixon/sidekiq-unique-jobs/pull/136)
23
+ - Close [#133](https://github.com/mhenrixon/sidekiq-unique-jobs/pull/133)
13
24
 
14
25
  ## v4.0.11
15
26
 
16
- - Always load forwardable - https://github.com/mhenrixon/sidekiq-unique-jobs/issues/152#issuecomment-164199978
27
+ - Always load forwardable [#152](https://github.com/mhenrixon/sidekiq-unique-jobs/issues/152#issuecomment-164199978)
17
28
 
18
29
  ## v4.0.10
19
30
 
20
- - Fix https://github.com/mhenrixon/sidekiq-unique-jobs/issues/152
31
+ - Fix [#152](https://github.com/mhenrixon/sidekiq-unique-jobs/issues/152)
21
32
  - Minor improvement to internal esthetics
22
33
 
23
34
  ## v4.0.9
@@ -26,18 +37,18 @@
26
37
 
27
38
  ## v4.0.8
28
39
 
29
- - Use unique arguments for the `WhileExecuting` lock (#127)
30
- - Delicensed code (#132)
31
- - Fix queuing unique jobs (#138)
40
+ - Use unique arguments for the `WhileExecuting` lock ([#127](https://github.com/mhenrixon/sidekiq-unique-jobs/issues/127)
41
+ - Delicensed code ([#132](https://github.com/mhenrixon/sidekiq-unique-jobs/issues/132)
42
+ - Fix queuing unique jobs ([#138](https://github.com/mhenrixon/sidekiq-unique-jobs/issues/138)
32
43
 
33
44
  ## v4.0.7
34
45
 
35
- - Use unique arguments for the `WhileExecuting` lock (#127)
46
+ - Use unique arguments for the `WhileExecuting` lock ([#127](https://github.com/mhenrixon/sidekiq-unique-jobs/issues/127)
36
47
  - See also https://github.com/mhenrixon/sidekiq-unique-jobs/releases/tag/v4.0.7
37
48
 
38
49
  ## v4.0.6
39
50
 
40
- - Removes enforced uniqueness for all jobs (#127)
51
+ - Removes enforced uniqueness for all jobs ([#127](https://github.com/mhenrixon/sidekiq-unique-jobs/issues/127)
41
52
 
42
53
  ## v4.0.5
43
54
 
data/Gemfile CHANGED
@@ -5,7 +5,7 @@ gem 'appraisal', '~> 2.0.0'
5
5
  gem 'rspec-its', require: false
6
6
  gem 'rspec-wait', require: false
7
7
 
8
- platform :mri_23 do
8
+ platforms :mri_23 do
9
9
  gem 'fasterer', require: false
10
10
  gem 'benchmark-ips', require: false
11
11
  gem 'pry-byebug', require: false
data/README.md CHANGED
@@ -101,7 +101,7 @@ For jobs scheduled in the future it is possible to set for how long the job
101
101
  should be unique. The job will be unique for the number of seconds configured (default 30 minutes)
102
102
  or until the job has been completed. Thus, the job will be unique for the shorter of the two. Note that Sidekiq versions before 3.0 will remove job keys after an hour, which means jobs can remain unique for at most an hour.
103
103
 
104
- *If you want the unique job to stick around even after it has been successfully
104
+ If you want the unique job to stick around even after it has been successfully
105
105
  processed then just set `unique: :until_timeout`.
106
106
 
107
107
  You can also control the expiration length of the uniqueness check. If you want to enforce uniqueness over a longer period than the default of 30 minutes then you can pass the number of seconds you want to use to the sidekiq options:
@@ -110,6 +110,12 @@ You can also control the expiration length of the uniqueness check. If you want
110
110
  sidekiq_options unique: :until_timeout, unique_expiration: 120 * 60 # 2 hours
111
111
  ```
112
112
 
113
+ For locking modes (`:while_executing` and `:until_and_while_executing`) you can control the expiration length of the runtime uniqueness. If you want to enforce uniqueness over a longer period than the default of 60 seconds, then you can pass the number of seconds you want to use to the sidekiq options:
114
+
115
+ ```ruby
116
+ sidekiq_options unique: :while_executing, run_lock_expiration: 2 * 60 # 2 minutes
117
+ ```
118
+
113
119
  Requiring the gem in your gemfile should be sufficient to enable unique jobs.
114
120
 
115
121
  ### Usage with ActiveJob
@@ -23,7 +23,8 @@ module SidekiqUniqueJobs
23
23
  def config
24
24
  @config ||= Config.new(
25
25
  unique_prefix: 'uniquejobs',
26
- default_expiration: 30 * 60,
26
+ default_queue_lock_expiration: 30 * 60,
27
+ default_run_lock_expiration: 60,
27
28
  default_lock: :while_executing,
28
29
  redis_test_mode: :redis # :mock
29
30
  )
@@ -2,7 +2,8 @@ module SidekiqUniqueJobs
2
2
  class Config < OpenStruct
3
3
  CONFIG_ACCESSORS = [
4
4
  :unique_prefix,
5
- :default_expiration,
5
+ :default_queue_lock_expiration,
6
+ :default_run_lock_expiration,
6
7
  :default_lock,
7
8
  :redis_mode
8
9
  ].freeze
@@ -5,6 +5,8 @@ module SidekiqUniqueJobs
5
5
  JID_KEY ||= 'jid'.freeze
6
6
  LOG_DUPLICATE_KEY ||= 'log_duplicate_payload'.freeze
7
7
  QUEUE_KEY ||= 'queue'.freeze
8
+ QUEUE_LOCK_TIMEOUT_KEY ||= 'unique_expiration'.freeze
9
+ RUN_LOCK_TIMEOUT_KEY ||= 'run_lock_expiration'.freeze
8
10
  TESTING_CONSTANT ||= 'Testing'.freeze
9
11
  UNIQUE_KEY ||= 'unique'.freeze
10
12
  UNIQUE_LOCK_KEY ||= 'unique_lock'.freeze
@@ -12,6 +14,5 @@ module SidekiqUniqueJobs
12
14
  UNIQUE_PREFIX_KEY ||= 'unique_prefix'.freeze
13
15
  UNIQUE_DIGEST_KEY ||= 'unique_digest'.freeze
14
16
  UNIQUE_ON_ALL_QUEUES_KEY ||= 'unique_on_all_queues'.freeze
15
- UNIQUE_TIMEOUT_KEY ||= 'unique_expiration'.freeze
16
17
  UNIQUE_ARGS_ENABLED_KEY ||= 'unique_args_enabled'.freeze
17
18
  end
@@ -58,7 +58,7 @@ module SidekiqUniqueJobs
58
58
  end
59
59
 
60
60
  def max_lock_time
61
- @max_lock_time ||= TimeoutCalculator.for_item(item).seconds
61
+ @max_lock_time ||= QueueLockTimeoutCalculator.for_item(item).seconds
62
62
  end
63
63
 
64
64
  def after_yield_yield
@@ -24,7 +24,13 @@ module SidekiqUniqueJobs
24
24
  end
25
25
 
26
26
  def locked?
27
- Scripts.call(:synchronize, @redis_pool, keys: [@unique_digest], argv: [Time.now.to_i]) == 1
27
+ Scripts.call(:synchronize, @redis_pool,
28
+ keys: [@unique_digest],
29
+ argv: [Time.now.to_i, max_lock_time]) == 1
30
+ end
31
+
32
+ def max_lock_time
33
+ @max_lock_time ||= RunLockTimeoutCalculator.for_item(@item).seconds
28
34
  end
29
35
 
30
36
  def execute(_callback)
@@ -54,7 +54,7 @@ module Sidekiq
54
54
  end
55
55
  end
56
56
 
57
- module UniqueExtension3_4
57
+ module UniqueExtension3_5
58
58
  def self.included(base)
59
59
  base.class_eval do
60
60
  include SidekiqUniqueJobs::Unlockable
@@ -75,9 +75,9 @@ module Sidekiq
75
75
  end
76
76
  end
77
77
  sidekiq_version = Gem::Version.new(Sidekiq::VERSION)
78
- include UniqueExtension3_4 if sidekiq_version >= Gem::Version.new('3.4')
78
+ include UniqueExtension3_5 if sidekiq_version >= Gem::Version.new('3.5')
79
79
  include UniqueExtension3_0 if sidekiq_version >= Gem::Version.new('3.0') &&
80
- sidekiq_version < Gem::Version.new('3.4')
80
+ sidekiq_version < Gem::Version.new('3.5')
81
81
  # rubocop:enable Style/ClassAndModuleCamelCase
82
82
  end
83
83
 
@@ -8,27 +8,22 @@ module SidekiqUniqueJobs
8
8
  @item = item
9
9
  end
10
10
 
11
- def seconds
12
- time_until_scheduled + unique_expiration
13
- end
14
-
15
11
  def time_until_scheduled
16
12
  scheduled = item[AT_KEY]
17
13
  return 0 unless scheduled
18
14
  (Time.at(scheduled) - Time.now.utc).to_i
19
15
  end
20
16
 
21
- def unique_expiration
22
- @unique_expiration ||=
23
- (
24
- worker_class_unique_expiration ||
25
- SidekiqUniqueJobs.config.default_expiration
26
- ).to_i
17
+ def seconds
18
+ raise NotImplementedError
27
19
  end
28
20
 
29
- def worker_class_unique_expiration
30
- return unless worker_class.respond_to?(:get_sidekiq_options)
31
- worker_class.get_sidekiq_options[UNIQUE_TIMEOUT_KEY]
21
+ def worker_class_queue_lock_expiration
22
+ worker_class_expiration_for QUEUE_LOCK_TIMEOUT_KEY
23
+ end
24
+
25
+ def worker_class_run_lock_expiration
26
+ worker_class_expiration_for RUN_LOCK_TIMEOUT_KEY
32
27
  end
33
28
 
34
29
  def worker_class
@@ -37,6 +32,34 @@ module SidekiqUniqueJobs
37
32
 
38
33
  private
39
34
 
35
+ def worker_class_expiration_for(key)
36
+ return unless worker_class.respond_to?(:get_sidekiq_options)
37
+ worker_class.get_sidekiq_options[key]
38
+ end
39
+
40
40
  attr_reader :item
41
41
  end
42
+
43
+ class RunLockTimeoutCalculator < TimeoutCalculator
44
+ def seconds
45
+ @seconds ||= (
46
+ worker_class_run_lock_expiration ||
47
+ SidekiqUniqueJobs.config.default_run_lock_expiration
48
+ ).to_i
49
+ end
50
+ end
51
+
52
+ class QueueLockTimeoutCalculator < TimeoutCalculator
53
+ def seconds
54
+ queue_lock_expiration + time_until_scheduled
55
+ end
56
+
57
+ def queue_lock_expiration
58
+ @queue_lock_expiration ||=
59
+ (
60
+ worker_class_queue_lock_expiration ||
61
+ SidekiqUniqueJobs.config.default_queue_lock_expiration
62
+ ).to_i
63
+ end
64
+ end
42
65
  end
@@ -1,3 +1,3 @@
1
1
  module SidekiqUniqueJobs
2
- VERSION = '4.0.15'.freeze
2
+ VERSION = '4.0.16'.freeze
3
3
  end
@@ -3,7 +3,7 @@ class SimpleWorker
3
3
  sidekiq_options unique: :until_executed,
4
4
  unique_args: -> (args) { [args.first] },
5
5
  queue: :default,
6
- default_expiration: 3 * 60 * 60
6
+ default_queue_lock_expiration: 3 * 60 * 60
7
7
 
8
8
  def perform(_some_arg)
9
9
  sleep 60
@@ -1,13 +1,14 @@
1
1
  local unique_key = KEYS[1]
2
2
  local time = ARGV[1]
3
+ local expires = ARGV[2]
3
4
 
4
- if redis.pcall('set', unique_key, time + 60, 'nx', 'ex', 60) then
5
+ if redis.pcall('set', unique_key, time + expires, 'nx', 'ex', expires) then
5
6
  return 1
6
7
  end
7
8
 
8
9
  local stored_time = redis.pcall('get', unique_key)
9
10
  if stored_time and stored_time < time then
10
- if redis.pcall('set', unique_key, time + 60, 'xx', 'ex', 60) then
11
+ if redis.pcall('set', unique_key, time + expires, 'xx', 'ex', expires) then
11
12
  return 1
12
13
  end
13
14
  end
@@ -0,0 +1,7 @@
1
+ class LongRunningJob
2
+ include Sidekiq::Worker
3
+ sidekiq_options queue: :customqueue, retry: true, unique: :until_and_while_executing,
4
+ run_lock_expiration: 7_200, retry_count: 10
5
+ def perform(_one, _two)
6
+ end
7
+ end
@@ -3,7 +3,7 @@ class SimpleWorker
3
3
  sidekiq_options unique: :until_executed,
4
4
  unique_args: ->(args) { [args.first] },
5
5
  queue: :default,
6
- default_expiration: 5 * 60 * 60
6
+ default_queue_lock_expiration: 5 * 60 * 60
7
7
 
8
8
  def perform(_arg)
9
9
  sleep 5
@@ -225,7 +225,8 @@ RSpec.describe SidekiqUniqueJobs::Client::Middleware do
225
225
  # jobs are set around the same time as the scheduled job itself feel free to improve.
226
226
  it 'expires the digest when a scheduled job is scheduled at' do
227
227
  expected_expires_at =
228
- (Time.at(Time.now.to_i + 15 * 60) - Time.now.utc) + SidekiqUniqueJobs.config.default_expiration
228
+ (Time.at(Time.now.to_i + 15 * 60) - Time.now.utc) +
229
+ SidekiqUniqueJobs.config.default_queue_lock_expiration
229
230
  jid = MyUniqueJob.perform_in(expected_expires_at, 'mike')
230
231
  item = { 'class' => MyUniqueJob,
231
232
  'queue' => 'customqueue',
@@ -31,6 +31,33 @@ RSpec.describe SidekiqUniqueJobs::Lock::WhileExecuting do
31
31
  expect(x).to eq(10)
32
32
  end
33
33
 
34
+ it 'expires the lock on the mutex object after run_lock_expiration if specified' do
35
+ mutexes = (1..10).map do
36
+ described_class.new(item)
37
+ end
38
+
39
+ worker = SidekiqUniqueJobs.worker_class_constantize(item[SidekiqUniqueJobs::CLASS_KEY])
40
+ allow(worker).to receive(:get_sidekiq_options)
41
+ .and_return('retry' => true,
42
+ 'queue' => :dupsallowed,
43
+ 'run_lock_expiration' => 0,
44
+ 'unique' => :until_and_while_executing)
45
+
46
+ start_times = []
47
+ sleep_time = 0.1
48
+ mutexes.each_with_index.map do |m, i|
49
+ Thread.new do
50
+ m.synchronize do
51
+ start_times[i] = Time.now
52
+ sleep sleep_time
53
+ end
54
+ end
55
+ end.map(&:join)
56
+
57
+ expect(start_times.size).to be 10
58
+ expect(start_times.sort.last - start_times.sort.first).to be < sleep_time * 10
59
+ end
60
+
34
61
  it 'handles auto cleanup correctly' do
35
62
  m = described_class.new(item)
36
63
 
@@ -0,0 +1,47 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe SidekiqUniqueJobs::QueueLockTimeoutCalculator do
4
+ shared_context 'generic unscheduled job' do
5
+ subject { described_class.new('class' => 'JustAWorker') }
6
+ end
7
+
8
+ describe 'public api' do
9
+ it_behaves_like 'generic unscheduled job' do
10
+ it { is_expected.to respond_to(:seconds) }
11
+ it { is_expected.to respond_to(:queue_lock_expiration) }
12
+ end
13
+ end
14
+
15
+ describe '.for_item' do
16
+ it 'initializes a new calculator' do
17
+ expect(described_class).to receive(:new).with('WAT')
18
+ described_class.for_item('WAT')
19
+ end
20
+ end
21
+
22
+ describe '#seconds' do
23
+ subject { described_class.new(nil) }
24
+
25
+ before do
26
+ allow(subject).to receive(:time_until_scheduled).and_return(10)
27
+ allow(subject).to receive(:queue_lock_expiration).and_return(9)
28
+ end
29
+ its(:seconds) { is_expected.to eq(19) }
30
+ end
31
+
32
+ describe '#queue_lock_expiration' do
33
+ context 'using default unique_expiration' do
34
+ subject { described_class.new(nil) }
35
+ before { allow(subject).to receive(:worker_class_queue_lock_expiration).and_return(nil) }
36
+
37
+ its(:queue_lock_expiration) { is_expected.to eq(1_800) }
38
+ end
39
+
40
+ context 'using specified sidekiq option unique_expiration' do
41
+ subject { described_class.new(nil) }
42
+ before { allow(subject).to receive(:worker_class_queue_lock_expiration).and_return(9) }
43
+
44
+ its(:queue_lock_expiration) { is_expected.to eq(9) }
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,36 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe SidekiqUniqueJobs::RunLockTimeoutCalculator do
4
+ shared_context 'generic unscheduled job' do
5
+ subject { described_class.new('class' => 'JustAWorker') }
6
+ end
7
+
8
+ describe 'public api' do
9
+ it_behaves_like 'generic unscheduled job' do
10
+ it { is_expected.to respond_to(:seconds) }
11
+ end
12
+ end
13
+
14
+ describe '.for_item' do
15
+ it 'initializes a new calculator' do
16
+ expect(described_class).to receive(:new).with('WAT')
17
+ described_class.for_item('WAT')
18
+ end
19
+ end
20
+
21
+ describe '#seconds' do
22
+ context 'using default run_lock_expiration' do
23
+ subject { described_class.new(nil) }
24
+ before { allow(subject).to receive(:worker_class_run_lock_expiration).and_return(9) }
25
+
26
+ its(:seconds) { is_expected.to eq(9) }
27
+ end
28
+
29
+ context 'using specified sidekiq option run_lock_expiration' do
30
+ subject { described_class.new(nil) }
31
+ before { allow(subject).to receive(:worker_class_run_lock_expiration).and_return(nil) }
32
+
33
+ its(:seconds) { is_expected.to eq(60) }
34
+ end
35
+ end
36
+ end
@@ -12,8 +12,8 @@ RSpec.describe SidekiqUniqueJobs::TimeoutCalculator do
12
12
  describe 'public api' do
13
13
  subject { described_class.new(nil) }
14
14
  it { is_expected.to respond_to(:time_until_scheduled) }
15
- it { is_expected.to respond_to(:unique_expiration) }
16
- it { is_expected.to respond_to(:worker_class_unique_expiration) }
15
+ it { is_expected.to respond_to(:worker_class_queue_lock_expiration) }
16
+ it { is_expected.to respond_to(:worker_class_run_lock_expiration) }
17
17
  it { is_expected.to respond_to(:worker_class) }
18
18
  it { is_expected.to respond_to(:seconds) }
19
19
  end
@@ -25,16 +25,6 @@ RSpec.describe SidekiqUniqueJobs::TimeoutCalculator do
25
25
  end
26
26
  end
27
27
 
28
- describe '#seconds' do
29
- subject { described_class.new(nil) }
30
-
31
- before do
32
- allow(subject).to receive(:time_until_scheduled).and_return(10)
33
- allow(subject).to receive(:unique_expiration).and_return(9)
34
- end
35
- its(:seconds) { is_expected.to eq(19) }
36
- end
37
-
38
28
  describe '#time_until_scheduled' do
39
29
  it_behaves_like 'item not scheduled' do
40
30
  its(:time_until_scheduled) { is_expected.to eq(0) }
@@ -51,22 +41,22 @@ RSpec.describe SidekiqUniqueJobs::TimeoutCalculator do
51
41
  end
52
42
  end
53
43
 
54
- describe '#unique_expiration' do
44
+ describe '#worker_class_queue_lock_expiration' do
55
45
  it_behaves_like 'undefined worker class' do
56
- its(:unique_expiration) { is_expected.to eq(SidekiqUniqueJobs.config.default_expiration) }
46
+ its(:worker_class_queue_lock_expiration) { is_expected.to eq(nil) }
57
47
  end
58
48
 
59
49
  subject { described_class.new('class' => 'MyUniqueJob') }
60
- its(:unique_expiration) { is_expected.to eq(7_200) }
50
+ its(:worker_class_queue_lock_expiration) { is_expected.to eq(7_200) }
61
51
  end
62
52
 
63
- describe '#worker_class_unique_expiration' do
53
+ describe '#worker_class_run_lock_expiration' do
64
54
  it_behaves_like 'undefined worker class' do
65
- its(:worker_class_unique_expiration) { is_expected.to eq(nil) }
55
+ its(:worker_class_run_lock_expiration) { is_expected.to eq(nil) }
66
56
  end
67
57
 
68
- subject { described_class.new('class' => 'MyUniqueJob') }
69
- its(:worker_class_unique_expiration) { is_expected.to eq(7_200) }
58
+ subject { described_class.new('class' => 'LongRunningJob') }
59
+ its(:worker_class_run_lock_expiration) { is_expected.to eq(7_200) }
70
60
  end
71
61
 
72
62
  describe '#worker_class' do
@@ -1,4 +1,4 @@
1
- if RUBY_ENGINE == 'ruby' && RUBY_VERSION >= '2.2.3'
1
+ if RUBY_ENGINE == 'ruby' && RUBY_VERSION >= '2.3.0'
2
2
  if ENV['CI']
3
3
  require 'codeclimate-test-reporter'
4
4
  CodeClimate::TestReporter.start
@@ -64,69 +64,3 @@ RSpec.configure do |config|
64
64
  end
65
65
 
66
66
  Dir[File.join(File.dirname(__FILE__), 'jobs', '**', '*.rb')].each { |f| require f }
67
- if RUBY_ENGINE == 'ruby' && RUBY_VERSION >= '2.2.3'
68
- if ENV['CI']
69
- require 'codeclimate-test-reporter'
70
- CodeClimate::TestReporter.start
71
- else
72
- require 'simplecov'
73
- end
74
-
75
- begin
76
- require 'pry-byebug'
77
- rescue LoadError
78
- puts 'Pry unavailable'
79
- end
80
- end
81
-
82
- require 'rspec'
83
- require 'rspec/its'
84
-
85
- require 'celluloid_with_fallback'
86
- require 'sidekiq'
87
- require 'sidekiq/util'
88
- require 'sidekiq-unique-jobs'
89
- require 'sidekiq_unique_jobs/testing'
90
- require 'timecop'
91
-
92
- require 'sidekiq/simulator'
93
-
94
- Sidekiq::Testing.disable!
95
- Sidekiq.logger.level = "Logger::#{ENV.fetch('LOGLEVEL') { 'error' }.upcase}".constantize
96
-
97
- require 'sidekiq/redis_connection'
98
-
99
- begin
100
- require 'redis-namespace'
101
- rescue LoadError
102
- puts 'Redis Namespace unavailable'
103
- end
104
-
105
- REDIS_URL ||= ENV['REDIS_URL'] || 'redis://localhost/15'.freeze
106
- REDIS_NAMESPACE ||= 'unique-test'.freeze
107
- REDIS_OPTIONS ||= { url: REDIS_URL }.freeze
108
- REDIS_OPTIONS[:namespace] = REDIS_NAMESPACE if defined?(Redis::Namespace)
109
- REDIS ||= Sidekiq::RedisConnection.create(REDIS_OPTIONS)
110
-
111
- Sidekiq.configure_client do |config|
112
- config.redis = REDIS_OPTIONS
113
- end
114
-
115
- Dir[File.join(File.dirname(__FILE__), 'support', '**', '*.rb')].each { |f| require f }
116
- RSpec.configure do |config|
117
- config.expect_with :rspec do |expectations|
118
- expectations.include_chain_clauses_in_custom_matcher_descriptions = true
119
- end
120
- config.mock_with :rspec do |mocks|
121
- mocks.verify_partial_doubles = true
122
- end
123
- config.filter_run :focus unless ENV['CI']
124
- config.run_all_when_everything_filtered = true
125
- config.disable_monkey_patching!
126
- config.warnings = false
127
- config.default_formatter = 'doc' if config.files_to_run.one?
128
- config.order = :random
129
- Kernel.srand config.seed
130
- end
131
-
132
- Dir[File.join(File.dirname(__FILE__), 'jobs', '**', '*.rb')].each { |f| require f }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidekiq-unique-jobs
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.15
4
+ version: 4.0.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mikael Henriksson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-16 00:00:00.000000000 Z
11
+ date: 2016-02-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sidekiq
@@ -116,6 +116,7 @@ executables:
116
116
  extensions: []
117
117
  extra_rdoc_files: []
118
118
  files:
119
+ - ".codeclimate.yml"
119
120
  - ".editorconfig"
120
121
  - ".fasterer.yml"
121
122
  - ".gitignore"
@@ -241,6 +242,7 @@ files:
241
242
  - spec/jobs/expiring_job.rb
242
243
  - spec/jobs/inline_worker.rb
243
244
  - spec/jobs/just_a_worker.rb
245
+ - spec/jobs/long_running_job.rb
244
246
  - spec/jobs/main_job.rb
245
247
  - spec/jobs/my_job.rb
246
248
  - spec/jobs/my_unique_job.rb
@@ -265,6 +267,8 @@ files:
265
267
  - spec/lib/sidekiq_unique_jobs/lock/while_executing_spec.rb
266
268
  - spec/lib/sidekiq_unique_jobs/normalizer_spec.rb
267
269
  - spec/lib/sidekiq_unique_jobs/options_with_fallback_spec.rb
270
+ - spec/lib/sidekiq_unique_jobs/queue_lock_timeout_calculator_spec.rb
271
+ - spec/lib/sidekiq_unique_jobs/run_lock_timeout_calculator_spec.rb
268
272
  - spec/lib/sidekiq_unique_jobs/scripts_spec.rb
269
273
  - spec/lib/sidekiq_unique_jobs/server/middleware_spec.rb
270
274
  - spec/lib/sidekiq_unique_jobs/sidekiq_testing_enabled_spec.rb
@@ -300,7 +304,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
300
304
  version: '0'
301
305
  requirements: []
302
306
  rubyforge_project:
303
- rubygems_version: 2.5.1
307
+ rubygems_version: 2.5.2
304
308
  signing_key:
305
309
  specification_version: 4
306
310
  summary: The unique jobs that were removed from sidekiq