sidekiq-unique-jobs 7.0.0.beta7 → 7.0.0.beta8

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
  SHA256:
3
- metadata.gz: e60f45b42352d0af4ffbe4d588ea5bc853ca0f9bdf9447448a70e514c4bb6f0d
4
- data.tar.gz: b76c27dba452a2714fad10a5e2287e395e3491e6732edc0e443dc91f558697d6
3
+ metadata.gz: 613b92887d9b07c1e2c0e485a553c3abd9b9586cc3a7026562b20fb1da751459
4
+ data.tar.gz: 3638999cdae0b55a4fdc1210ac38aa96782ac139dacb5167692921fd061f7a0f
5
5
  SHA512:
6
- metadata.gz: aa23d4e215b263e09f7bfbf515a90e7b5260ca9ea6ccc442ecfc9068f9b9534befafe765133b932336c4e1592224c464ebc15a64cf4cf8b462942121d2e45c2e
7
- data.tar.gz: 689266ff97106bc2d81cea9724f87b220518fac799e9945706de28ffc19824e88c41f44245ac52ef5e10918607597f8ad4ad3f557ae57f2bd877d7b7627597b5
6
+ metadata.gz: 613e5e3feeb4e61eee2d2d64a6a648bcef199526b42ad0ef682ead1f91ba6efa8945d01f1ba0379ae5acc4f44e27377ab320990db68822449ab3dab0a4bbb85f
7
+ data.tar.gz: 8802925c25b1f32552dcaf6329a90c4c9f825ea828f85c2c7570a2a359fa0cbf20f4102d5908c27e2ea210f671b7ac2b878096a1b6e905222faf5d1e357d3d5c
data/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # Changelog
2
2
 
3
+ ## [v7.0.0.beta7](https://github.com/mhenrixon/sidekiq-unique-jobs/tree/v7.0.0.beta7) (2019-11-28)
4
+
5
+ [Full Changelog](https://github.com/mhenrixon/sidekiq-unique-jobs/compare/v7.0.0.beta6...v7.0.0.beta7)
6
+
7
+ **Fixed bugs:**
8
+
9
+ - A worker with "While Executing" lock and "Reschedule" strategy is rescheduled forever [\#457](https://github.com/mhenrixon/sidekiq-unique-jobs/issues/457)
10
+ - Prevent callbacks from preventing locks [\#460](https://github.com/mhenrixon/sidekiq-unique-jobs/pull/460) ([mhenrixon](https://github.com/mhenrixon))
11
+
3
12
  ## [v7.0.0.beta6](https://github.com/mhenrixon/sidekiq-unique-jobs/tree/v7.0.0.beta6) (2019-11-28)
4
13
 
5
14
  [Full Changelog](https://github.com/mhenrixon/sidekiq-unique-jobs/compare/v6.0.18...v7.0.0.beta6)
@@ -760,7 +769,6 @@
760
769
 
761
770
  - Seeing this error with latest version 4.0.12 [\#154](https://github.com/mhenrixon/sidekiq-unique-jobs/issues/154)
762
771
  - Unique job showing weird behavior [\#153](https://github.com/mhenrixon/sidekiq-unique-jobs/issues/153)
763
- - perform\_in not working in version 4.0.9 [\#150](https://github.com/mhenrixon/sidekiq-unique-jobs/issues/150)
764
772
 
765
773
  ## [v4.0.12](https://github.com/mhenrixon/sidekiq-unique-jobs/tree/v4.0.12) (2015-12-15)
766
774
 
@@ -769,6 +777,7 @@
769
777
  **Closed issues:**
770
778
 
771
779
  - Can't schedule a job from another job [\#151](https://github.com/mhenrixon/sidekiq-unique-jobs/issues/151)
780
+ - perform\_in not working in version 4.0.9 [\#150](https://github.com/mhenrixon/sidekiq-unique-jobs/issues/150)
772
781
  - `unique: until\_and\_while\_executing` not working as expected [\#146](https://github.com/mhenrixon/sidekiq-unique-jobs/issues/146)
773
782
  - while\_executing still runs duplicate tasks [\#136](https://github.com/mhenrixon/sidekiq-unique-jobs/issues/136)
774
783
  - Version 4 Upgrade [\#133](https://github.com/mhenrixon/sidekiq-unique-jobs/issues/133)
data/README.md CHANGED
@@ -33,27 +33,15 @@
33
33
  - [While Executing](#while-executing)
34
34
  - [Custom Locks](#custom-locks)
35
35
  - [Conflict Strategy](#conflict-strategy)
36
- - [log](#log)
37
- - [raise](#raise)
38
- - [reject](#reject)
39
- - [replace](#replace)
40
- - [Reschedule](#reschedule)
41
- - [Custom Strategies](#custom-strategies)
42
- - [Usage](#usage)
43
- - [Finer Control over Uniqueness](#finer-control-over-uniqueness)
44
- - [After Unlock Callback](#after-unlock-callback)
45
- - [Logging](#logging)
46
- - [Cleanup Dead Locks](#cleanup-dead-locks)
47
- - [Other Sidekiq gems](#other-sidekiq-gems)
48
- - [sidekiq-global_id](#sidekiq-global_id)
49
- - [Debugging](#debugging)
50
- - [Sidekiq Web](#sidekiq-web)
51
- - [Show Locks](#show-locks)
52
- - [Show Lock](#show-lock)
53
- - [Communication](#communication)
54
- - [Testing](#testing)
55
- - [Unique Sidekiq Configuration](#unique-sidekiq-configuration)
56
- - [Uniqueness](#uniqueness)
36
+ - [lib/strategies/my_custom_strategy.rb](#libstrategiesmycustomstrategyrb)
37
+ - [For rails application](#for-rails-application)
38
+ - [config/initializers/sidekiq_unique_jobs.rb](#configinitializerssidekiquniquejobsrb)
39
+ - [For other projects, whenever you prefer](#for-other-projects-whenever-you-prefer)
40
+ - [this goes in your initializer](#this-goes-in-your-initializer)
41
+ - [app/config/routes.rb](#appconfigroutesrb)
42
+ - [app/workers/bad_worker.rb](#appworkersbad_workerrb)
43
+ - [spec/workers/bad_worker_spec.rb](#specworkersbadworkerspecrb)
44
+ - [OR](#or)
57
45
  - [Contributing](#contributing)
58
46
  - [Contributors](#contributors)
59
47
 
@@ -415,7 +403,12 @@ Please not that if you try to override a default lock, an `ArgumentError` will b
415
403
 
416
404
  Decides how we handle conflict. We can either reject the job to the dead queue or reschedule it. Both are useful for jobs that absolutely need to run and have been configured to use the lock `WhileExecuting` that is used only by the sidekiq server process.
417
405
 
418
- The last one is log which can be be used with the lock `UntilExecuted` and `UntilExpired`. Now we write a log entry saying the job could not be pushed because it is a duplicate of another job with the same arguments
406
+ The last one is log which can be be used with the lock `UntilExecuted` and `UntilExpired`. Now we write a log entry saying the job could not be pushed because it is a duplicate of another job with the same arguments.
407
+
408
+ It is possible for locks to have different conflict strategy for the client and server. This is useful for `:until_and_while_executing`.
409
+
410
+ ```ruby
411
+ sidekiq_options lock: :until_and_while_executing, on_conflict: { client: :log, server: :reject }
419
412
 
420
413
  ### log
421
414
 
@@ -29,6 +29,7 @@ module SidekiqUniqueJobs
29
29
  @redis_pool = redis_pool
30
30
  @attempt = 0
31
31
  add_uniqueness_when_missing # Used to ease testing
32
+ @lock_config = LockConfig.new(item)
32
33
  end
33
34
 
34
35
  #
@@ -41,7 +42,6 @@ module SidekiqUniqueJobs
41
42
  # @yield to the caller when given a block
42
43
  #
43
44
  def lock(&block)
44
- # TODO: only use replace strategy when server is executing the lock
45
45
  return call_strategy unless (locked_token = locksmith.lock(&block))
46
46
 
47
47
  locked_token
@@ -100,16 +100,19 @@ module SidekiqUniqueJobs
100
100
 
101
101
  def call_strategy
102
102
  @attempt += 1
103
- strategy.call { lock if replace? }
103
+ client_strategy.call { lock if replace? }
104
104
  end
105
105
 
106
106
  def replace?
107
- strategy.replace? && attempt < 2
107
+ client_strategy.replace? && attempt < 2
108
108
  end
109
109
 
110
110
  # @!attribute [r] item
111
111
  # @return [Hash<String, Object>] the Sidekiq job hash
112
112
  attr_reader :item
113
+ # @!attribute [r] lock_config
114
+ # @return [LockConfig] a lock configuration
115
+ attr_reader :lock_config
113
116
  # @!attribute [r] redis_pool
114
117
  # @return [Sidekiq::RedisConnection, ConnectionPool, NilClass] the redis connection
115
118
  attr_reader :redis_pool
@@ -135,8 +138,14 @@ module SidekiqUniqueJobs
135
138
  raise
136
139
  end
137
140
 
138
- def strategy
139
- @strategy ||= OnConflict.find_strategy(item[ON_CONFLICT]).new(item, redis_pool)
141
+ def client_strategy
142
+ @client_strategy ||=
143
+ OnConflict.find_strategy(lock_config.on_client_conflict).new(item, redis_pool)
144
+ end
145
+
146
+ def server_strategy
147
+ @server_strategy ||=
148
+ OnConflict.find_strategy(lock_config.on_server_conflict).new(item, redis_pool)
140
149
  end
141
150
  end
142
151
  end
@@ -37,7 +37,7 @@ module SidekiqUniqueJobs
37
37
  # @yield to the worker class perform method
38
38
  def execute
39
39
  with_logging_context do
40
- strategy.call unless locksmith.lock do
40
+ server_strategy&.call unless locksmith.lock do
41
41
  yield
42
42
  callback_safely
43
43
  end
@@ -13,8 +13,8 @@ module SidekiqUniqueJobs
13
13
  class WhileExecutingReject < WhileExecuting
14
14
  # Overridden with a forced {OnConflict::Reject} strategy
15
15
  # @return [OnConflict::Reject] a reject strategy
16
- def strategy
17
- @strategy ||= OnConflict.find_strategy(:reject).new(item, redis_pool)
16
+ def server_strategy
17
+ @server_strategy ||= OnConflict.find_strategy(:reject).new(item, redis_pool)
18
18
  end
19
19
  end
20
20
  end
@@ -3,5 +3,5 @@
3
3
  module SidekiqUniqueJobs
4
4
  #
5
5
  # @return [String] the current SidekiqUniqueJobs version
6
- VERSION = "7.0.0.beta7"
6
+ VERSION = "7.0.0.beta8"
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidekiq-unique-jobs
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.0.0.beta7
4
+ version: 7.0.0.beta8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mikael Henriksson