sidekiq-unique-jobs 6.0.0.rc6 → 6.0.0.rc7

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.

Files changed (85) hide show
  1. checksums.yaml +4 -4
  2. data/.codeclimate.yml +6 -7
  3. data/.github/ISSUE_TEMPLATE/bug_report.md +1 -1
  4. data/.reek.yml +17 -48
  5. data/.rubocop.yml +3 -0
  6. data/.yardopts +7 -0
  7. data/CHANGELOG.md +2 -0
  8. data/README.md +65 -23
  9. data/assets/unique_digests_1.png +0 -0
  10. data/assets/unique_digests_2.png +0 -0
  11. data/examples/another_unique_job.rb +4 -2
  12. data/examples/custom_queue_job_with_filter_method.rb +1 -1
  13. data/examples/custom_queue_job_with_filter_proc.rb +1 -1
  14. data/examples/expiring_job.rb +1 -1
  15. data/examples/inline_worker.rb +1 -1
  16. data/examples/just_a_worker.rb +1 -1
  17. data/examples/long_running_job.rb +4 -2
  18. data/examples/main_job.rb +3 -2
  19. data/examples/my_unique_job.rb +4 -5
  20. data/examples/my_unique_job_with_filter_method.rb +3 -3
  21. data/examples/my_unique_job_with_filter_proc.rb +3 -3
  22. data/examples/notify_worker.rb +2 -2
  23. data/examples/simple_worker.rb +2 -2
  24. data/examples/unique_across_workers_job.rb +1 -1
  25. data/examples/unique_job_on_conflict_raise.rb +14 -0
  26. data/examples/unique_job_on_conflict_reject.rb +14 -0
  27. data/examples/unique_job_on_conflict_reschedule.rb +14 -0
  28. data/examples/unique_job_with_conditional_parameter.rb +3 -3
  29. data/examples/unique_job_with_filter_method.rb +5 -2
  30. data/examples/unique_job_with_nil_unique_args.rb +3 -3
  31. data/examples/unique_job_with_no_unique_args_method.rb +3 -3
  32. data/examples/unique_job_withthout_unique_args_parameter.rb +3 -3
  33. data/examples/unique_on_all_queues_job.rb +1 -1
  34. data/examples/until_and_while_executing_job.rb +4 -1
  35. data/examples/until_executed_2_job.rb +5 -5
  36. data/examples/until_executed_job.rb +5 -5
  37. data/examples/until_executing_job.rb +1 -1
  38. data/examples/until_expired_job.rb +1 -1
  39. data/examples/until_global_expired_job.rb +1 -1
  40. data/examples/while_executing_job.rb +2 -2
  41. data/examples/while_executing_reject_job.rb +2 -2
  42. data/examples/without_argument_job.rb +1 -1
  43. data/lib/sidekiq_unique_jobs.rb +30 -0
  44. data/lib/sidekiq_unique_jobs/client/middleware.rb +12 -1
  45. data/lib/sidekiq_unique_jobs/connection.rb +5 -1
  46. data/lib/sidekiq_unique_jobs/constants.rb +3 -0
  47. data/lib/sidekiq_unique_jobs/digests.rb +111 -0
  48. data/lib/sidekiq_unique_jobs/exceptions.rb +15 -16
  49. data/lib/sidekiq_unique_jobs/lock/base_lock.rb +44 -3
  50. data/lib/sidekiq_unique_jobs/lock/until_and_while_executing.rb +13 -3
  51. data/lib/sidekiq_unique_jobs/lock/until_executed.rb +8 -1
  52. data/lib/sidekiq_unique_jobs/lock/until_executing.rb +8 -1
  53. data/lib/sidekiq_unique_jobs/lock/until_expired.rb +14 -2
  54. data/lib/sidekiq_unique_jobs/lock/while_executing.rb +19 -5
  55. data/lib/sidekiq_unique_jobs/lock/while_executing_reject.rb +16 -63
  56. data/lib/sidekiq_unique_jobs/locksmith.rb +36 -13
  57. data/lib/sidekiq_unique_jobs/logging.rb +24 -1
  58. data/lib/sidekiq_unique_jobs/normalizer.rb +6 -0
  59. data/lib/sidekiq_unique_jobs/on_conflict.rb +24 -0
  60. data/lib/sidekiq_unique_jobs/on_conflict/log.rb +20 -0
  61. data/lib/sidekiq_unique_jobs/on_conflict/null_strategy.rb +16 -0
  62. data/lib/sidekiq_unique_jobs/on_conflict/raise.rb +17 -0
  63. data/lib/sidekiq_unique_jobs/on_conflict/reject.rb +72 -0
  64. data/lib/sidekiq_unique_jobs/on_conflict/reschedule.rb +24 -0
  65. data/lib/sidekiq_unique_jobs/on_conflict/strategy.rb +28 -0
  66. data/lib/sidekiq_unique_jobs/options_with_fallback.rb +19 -4
  67. data/lib/sidekiq_unique_jobs/scripts.rb +31 -0
  68. data/lib/sidekiq_unique_jobs/server/middleware.rb +10 -0
  69. data/lib/sidekiq_unique_jobs/sidekiq_worker_methods.rb +15 -1
  70. data/lib/sidekiq_unique_jobs/timeout/calculator.rb +17 -4
  71. data/lib/sidekiq_unique_jobs/unique_args.rb +47 -5
  72. data/lib/sidekiq_unique_jobs/unlockable.rb +10 -0
  73. data/lib/sidekiq_unique_jobs/util.rb +12 -7
  74. data/lib/sidekiq_unique_jobs/version.rb +1 -1
  75. data/lib/sidekiq_unique_jobs/web.rb +51 -0
  76. data/lib/sidekiq_unique_jobs/web/helpers.rb +37 -0
  77. data/lib/sidekiq_unique_jobs/web/views/unique_digest.erb +28 -0
  78. data/lib/sidekiq_unique_jobs/web/views/unique_digests.erb +42 -0
  79. data/redis/create.lua +4 -2
  80. data/redis/delete.lua +3 -1
  81. data/redis/delete_by_digest.lua +22 -0
  82. data/redis/signal.lua +3 -1
  83. data/sidekiq-unique-jobs.gemspec +2 -0
  84. metadata +49 -3
  85. data/lib/sidekiq_unique_jobs/lock/while_executing_requeue.rb +0 -21
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a18917b728c376204bb49c0d25e9114c5a512aaff454cb2276fc3de1f9bc9044
4
- data.tar.gz: fab057843aa50766cb6adedcdf180aea0e67eba70ed4db8bf700c710621db47a
3
+ metadata.gz: c90e3f7dec1b958a7516b7fe9aa703622abba4e7713c1e18d3022c6f853822b2
4
+ data.tar.gz: b3597746d75ce16841f2dc91bd5ba1377850f1341e4bece3478f803f61840979
5
5
  SHA512:
6
- metadata.gz: c9797381413519ef4901151f3db6087681c292e4d163b23b4f616e4f5da2bcec47356c53a9da9b03333c86eabade31a58786e0c1c14a3aadbffa25841d1f5dcb
7
- data.tar.gz: b409a5e4f6f09b912f64f6326da125e9041c2f73964202710e2d396a211acdf5e41e9b72e52aa1b26795bfe98e0309ebbc99d7d6b2d4417e9aaeeadab316e226
6
+ metadata.gz: fd3fb117d369c9e5ce97d5ea175813e50f76ae59c41cc6aaf91accc9bc613a0cefffd8d20420d854a7378125b0108ddef603011bc0fede46fa0addd7785ef057
7
+ data.tar.gz: 9d416d37175611a6de8d8dbe9e416218f5439a9760577d7b337df7b0b8f21da2d35c8a0a4ba4846d8490fe26fa467f21f258c5645701cf81fb9e87d276243434
data/.codeclimate.yml CHANGED
@@ -8,22 +8,21 @@ plugins:
8
8
  config:
9
9
  languages:
10
10
  - ruby
11
- # editorconfig:
12
- # enabled: true
13
- # channel: beta
14
- # config:
15
- # editorconfig: .editorconfig
16
11
  flog:
17
12
  enabled: true
18
13
  fixme:
19
14
  enabled: true
20
15
  markdownlint:
21
- enabled: true
16
+ enabled: true
22
17
  reek:
23
18
  enabled: true
19
+ config:
20
+ file: .reek.yml
24
21
  rubocop:
25
22
  enabled: true
26
- channel: rubocop-0-54
23
+ channel: rubocop-0-57
24
+ config:
25
+ file: .rubocop.yml
27
26
  exclude_patterns:
28
27
  - Gemfile
29
28
  - "*.gemspec"
@@ -18,7 +18,7 @@ What happens instead of the expected behavior?
18
18
  ```ruby
19
19
  class MyWorker
20
20
  include Sidekiq::Worker
21
- sidekiq_options unique: :until_executed, queue: :undefault
21
+ sidekiq_options lock: :until_executed, queue: :undefault
22
22
  def perform(args); end
23
23
 
24
24
  def self.unique_args(args)
data/.reek.yml CHANGED
@@ -10,54 +10,17 @@ detectors:
10
10
  DuplicateMethodCall:
11
11
  exclude:
12
12
  - Sidekiq#self.use_options
13
+ - SidekiqUniqueJobs::Web#self.registered
13
14
  IrresponsibleModule:
15
+ enabled: false
16
+ LongParameterList:
17
+ enabled: true
14
18
  exclude:
15
- - Sidekiq::Simulator
16
- - SidekiqUniqueJobs::Cli
17
- - SidekiqUniqueJobs::Client::Middleware
18
- - SidekiqUniqueJobs
19
- - Array
20
- - Hash
21
- - SidekiqUniqueJobs::JidMissing
22
- - SidekiqUniqueJobs::LockTimeout
23
- - SidekiqUniqueJobs::MaxLockTimeMissing
24
- - SidekiqUniqueJobs::RunLockFailed
25
- - SidekiqUniqueJobs::ScriptError
26
- - SidekiqUniqueJobs::UnexpectedValue
27
- - SidekiqUniqueJobs::UniqueKeyMissing
28
- - SidekiqUniqueJobs::UnknownLock
29
- - SidekiqUniqueJobs::Lock::BaseLock
30
- - SidekiqUniqueJobs::Lock::UntilAndWhileExecuting
31
- - SidekiqUniqueJobs::Lock::UntilExecuted
32
- - SidekiqUniqueJobs::Lock::UntilExecuting
33
- - SidekiqUniqueJobs::Lock::UntilExpired
34
- - SidekiqUniqueJobs::Lock::WhileExecuting
35
- - SidekiqUniqueJobs::Lock::WhileExecutingReject
36
- - SidekiqUniqueJobs::Lock::WhileExecutingRequeue
37
- - SidekiqUniqueJobs::Locksmith
38
- - SidekiqUniqueJobs::Middleware
39
- - SidekiqUniqueJobs::Normalizer
40
- - SidekiqUniqueJobs::Scripts
41
- - SidekiqUniqueJobs::Server::Middleware
42
- - Sidekiq::Job
43
- - Sidekiq::Job::UniqueExtension
44
- - Sidekiq::JobSet
45
- - Sidekiq::JobSet::UniqueExtension
46
- - Sidekiq::Queue
47
- - Sidekiq::Queue::UniqueExtension
48
- - Sidekiq::ScheduledSet
49
- - Sidekiq::ScheduledSet::UniqueExtension
50
- - Sidekiq::SortedEntry
51
- - Sidekiq::SortedEntry::UniqueExtension
52
- - Sidekiq
53
- - Sidekiq::Worker
54
- - Sidekiq::Worker::ClassMethods
55
- - Sidekiq::Worker::Overrides
56
- - Sidekiq::Worker::Overrides::Testing
57
- - SidekiqUniqueJobs::Timeout::Calculator
58
- - SidekiqUniqueJobs::Timeout
59
- - SidekiqUniqueJobs::Unlockable
60
- - SidekiqUniqueJobs::Util
19
+ - initialize
20
+ - Hash#slice
21
+ - SidekiqUniqueJobs::Locksmith#create_lock
22
+ - SidekiqUniqueJobs::Locksmith#expire_when_necessary
23
+ - SidekiqUniqueJobs::Client::Middleware#call
61
24
  TooManyStatements:
62
25
  exclude:
63
26
  - initialize
@@ -68,6 +31,9 @@ detectors:
68
31
  - SidekiqUniqueJobs::Server::Middleware#call
69
32
  - SidekiqUniqueJobs::UniqueArgs#filtered_args
70
33
  - SidekiqUniqueJobs::Util#del
34
+ - SidekiqUniqueJobs::Digests#batch_delete
35
+ - SidekiqUniqueJobs::Digests#delete_by_pattern
36
+ - SidekiqUniqueJobs::Web#self.registered
71
37
  UncommunicativeVariableName:
72
38
  exclude:
73
39
  - Hash#slice
@@ -84,8 +50,9 @@ detectors:
84
50
  exclude:
85
51
  - Hash#slice
86
52
  - Hash#slice!
87
- - SidekiqUniqueJobs::Lock::WhileExecutingReject#deadset_kill?
53
+ - SidekiqUniqueJobs::OnConflict::Reject#deadset_kill?
88
54
  - SidekiqUniqueJobs::SidekiqWorkerMethods#worker_method_defined?
55
+ - SidekiqUniqueJobs::Web::Helpers#redirect_to
89
56
  MissingSafeMethod:
90
57
  exclude:
91
58
  - Array
@@ -93,15 +60,17 @@ detectors:
93
60
  enabled: false
94
61
  FeatureEnvy:
95
62
  exclude:
96
- - SidekiqUniqueJobs::Lock::WhileExecutingReject#push_to_deadset
63
+ - SidekiqUniqueJobs::OnConflict::Reject#push_to_deadset
97
64
  - SidekiqUniqueJobs::Logging#debug_item
98
65
  - SidekiqUniqueJobs::Util#batch_delete
66
+ - SidekiqUniqueJobs::Digests#batch_delete
99
67
  NestedIterators:
100
68
  exclude:
101
69
  - SidekiqUniqueJobs::Locksmith#create_lock
102
70
  - SidekiqUniqueJobs::Middleware#configure_client_middleware
103
71
  - SidekiqUniqueJobs::Middleware#configure_server_middleware
104
72
  - SidekiqUniqueJobs::Util#batch_delete
73
+ - SidekiqUniqueJobs::Digests#batch_delete
105
74
  TooManyInstanceVariables:
106
75
  exclude:
107
76
  - SidekiqUniqueJobs::Locksmith
data/.rubocop.yml CHANGED
@@ -64,6 +64,9 @@ RSpec/ExampleLength:
64
64
  RSpec/ExpectActual:
65
65
  Enabled: false
66
66
 
67
+ RSpec/ExpectChange:
68
+ Enabled: false
69
+
67
70
  RSpec/ExpectInHook:
68
71
  Enabled: false
69
72
 
data/.yardopts ADDED
@@ -0,0 +1,7 @@
1
+ --no-private
2
+ --exclude lib/sidekiq_unique_jobs/testing.rb
3
+ --exclude lib/sidekiq_unique_jobs/sidekiq_unique_ext.rb
4
+ --exclude lib/sidekiq_unique_jobs/middleware.rb
5
+ --exclude lib/sidekiq_unique_jobs/core_ext.rb
6
+ --exclude lib/sidekiq_unique_jobs/cli.rb
7
+
data/CHANGELOG.md CHANGED
@@ -11,6 +11,8 @@
11
11
  - Removed concurrency for now (a0cff5bc42edbe7190d6ede7e7f845074d2d7af6)
12
12
  - Improved integration testing for locks
13
13
  - Totally delete the hash that was growing out of proportion
14
+ - Adds a sidekiq web extension for viewing and deleting unique digests
15
+ - Renamed the configuration `unique:` to `lock:` (still backwards compatible)
14
16
 
15
17
  ## v5.1.0
16
18
 
data/README.md CHANGED
@@ -6,6 +6,7 @@
6
6
  * [Documentation](#documentation)
7
7
  * [Requirements](#requirements)
8
8
  * [Installation](#installation)
9
+ * [Support Me](#support-me)
9
10
  * [General Information](#general-information)
10
11
  * [Options](#options)
11
12
  * [Lock Expiration](#lock-expiration)
@@ -18,15 +19,13 @@
18
19
  * [Until Timeout](#until-timeout)
19
20
  * [Unique Until And While Executing](#unique-until-and-while-executing)
20
21
  * [While Executing](#while-executing)
22
+ * [Conflict Strategy](#conflict-strategy)
21
23
  * [Usage](#usage)
22
24
  * [Finer Control over Uniqueness](#finer-control-over-uniqueness)
23
25
  * [After Unlock Callback](#after-unlock-callback)
24
26
  * [Logging](#logging)
25
27
  * [Debugging](#debugging)
26
- * [Console](#console)
27
- * [List Unique Keys](#list-unique-keys)
28
- * [Remove Unique Keys](#remove-unique-keys)
29
- * [Command Line](#command-line)
28
+ * [Sidekiq Web](#sidekiq-web)
30
29
  * [Communication](#communication)
31
30
  * [Testing](#testing)
32
31
  * [Contributing](#contributing)
@@ -65,6 +64,11 @@ Or install it yourself as:
65
64
 
66
65
  $ gem install sidekiq-unique-jobs
67
66
 
67
+
68
+ ## Support Me
69
+
70
+ Want to show me some ❤️ for the hard work I do on this gem? You can use the following PayPal link https://paypal.me/mhenrixon. Any amount is welcome and let me tell you it feels good to be appreciated. Even a dollar makes me super excited about all of this.
71
+
68
72
  ## General Information
69
73
 
70
74
  See [Interaction w/ Sidekiq](https://github.com/mhenrixon/sidekiq-unique-jobs/wiki/How-this-gem-interacts-with-Sidekiq) on how the gem interacts with Sidekiq.
@@ -150,7 +154,7 @@ Locks from when the client pushes the job to the queue. Will be unlocked before
150
154
  **NOTE** this is probably not so good for jobs that shouldn't be running simultaneously (aka slow jobs).
151
155
 
152
156
  ```ruby
153
- sidekiq_options unique: :until_executing
157
+ sidekiq_options lock: :until_executing
154
158
  ```
155
159
 
156
160
  ### Until Executed
@@ -158,7 +162,7 @@ sidekiq_options unique: :until_executing
158
162
  Locks from when the client pushes the job to the queue. Will be unlocked when the server has successfully processed the job.
159
163
 
160
164
  ```ruby
161
- sidekiq_options unique: :until_executed
165
+ sidekiq_options lock: :until_executed
162
166
  ```
163
167
 
164
168
  ### Until Timeout
@@ -166,7 +170,7 @@ sidekiq_options unique: :until_executed
166
170
  Locks from when the client pushes the job to the queue. Will be unlocked when the specified timeout has been reached.
167
171
 
168
172
  ```ruby
169
- sidekiq_options unique: :until_expired
173
+ sidekiq_options lock: :until_expired
170
174
  ```
171
175
 
172
176
  ### Unique Until And While Executing
@@ -174,7 +178,7 @@ sidekiq_options unique: :until_expired
174
178
  Locks when the client pushes the job to the queue. The queue will be unlocked when the server starts processing the job. The server then goes on to creating a runtime lock for the job to prevent simultaneous jobs from being executed. As soon as the server starts processing a job, the client can push the same job to the queue.
175
179
 
176
180
  ```ruby
177
- sidekiq_options unique: :until_and_while_executing
181
+ sidekiq_options lock: :until_and_while_executing
178
182
  ```
179
183
 
180
184
  ### While Executing
@@ -184,7 +188,7 @@ With this lock type it is possible to put any number of these jobs on the queue,
184
188
  **NOTE** Unless this job is configured with a `lock_timeout: nil` or `lock_timeout: > 0` then all jobs that are attempted to be executed will just be dropped without waiting.
185
189
 
186
190
  ```ruby
187
- sidekiq_options unique: :while_executing, lock_timeout: nil
191
+ sidekiq_options lock: :while_executing, lock_timeout: nil
188
192
  ```
189
193
 
190
194
  There is an example of this to try it out in the `rails_example` application. Run `foreman start` in the root of the directory and open the url: `localhost:5000/work/duplicate_while_executing`.
@@ -206,12 +210,42 @@ In the console you should see something like:
206
210
  10:33:04 worker.1 | 2017-04-23T08:33:04.973Z 84404 TID-ougq8cs8s WhileExecutingWorker JID-9e197460c067b22eb1b5d07f INFO: done: 40.014 sec
207
211
  ```
208
212
 
213
+ ## Conflict Strategy
214
+
215
+ 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.
216
+
217
+ 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
218
+
219
+ ### Raise
220
+
221
+ This strategy is intended to be used with `WhileExecuting`. Basically it will allow us to let the server process crash with a specific error message and be retried without messing up the Sidekiq stats.
222
+
223
+ `sidekiq_options lock: :while_executing, on_conflict: :raise, retry: 10`
224
+
225
+ ### Reject
226
+
227
+ This strategy is intended to be used with `WhileExecuting` and will push the job to the dead queue on conflict.
228
+
229
+ `sidekiq_options lock: :while_executing, on_conflict: :reject`
230
+
231
+ ### Reschedule
232
+
233
+ This strategy is intended to be used with `WhileExecuting` and will delay the job to be tried again in 5 seconds. This will mess up the sidekiq stats but will prevent exceptions from being logged and confuse your sysadmins.
234
+
235
+ `sidekiq_options lock: :while_executing, on_conflict: :reschedule`
236
+
237
+ ### Log
238
+
239
+ This strategy is intended to be used with `UntilExecuted` and `UntilExpired`. It will log a line about that this is job is a duplicate of another.
240
+
241
+ `sidekiq_options lock: :until_executed, on_conflict: :log`
242
+
209
243
  ## Usage
210
244
 
211
245
  All that is required is that you specifically set the sidekiq option for _unique_ to a valid value like below:
212
246
 
213
247
  ```ruby
214
- sidekiq_options unique: :while_executing
248
+ sidekiq_options lock: :while_executing
215
249
  ```
216
250
 
217
251
  Requiring the gem in your gemfile should be sufficient to enable unique jobs.
@@ -227,7 +261,7 @@ The method or the proc can return a modified version of args without the transie
227
261
  ```ruby
228
262
  class UniqueJobWithFilterMethod
229
263
  include Sidekiq::Worker
230
- sidekiq_options unique: :until_and_while_executing,
264
+ sidekiq_options lock: :until_and_while_executing,
231
265
  unique_args: :unique_args # this is default and will be used if such a method is defined
232
266
 
233
267
  def self.unique_args(args)
@@ -240,7 +274,7 @@ end
240
274
 
241
275
  class UniqueJobWithFilterProc
242
276
  include Sidekiq::Worker
243
- sidekiq_options unique: :until_executed,
277
+ sidekiq_options lock: :until_executed,
244
278
  unique_args: ->(args) { [ args.first ] }
245
279
 
246
280
  ...
@@ -253,7 +287,7 @@ It is also quite possible to ensure different types of unique args based on cont
253
287
  ```ruby
254
288
  class UniqueJobWithFilterMethod
255
289
  include Sidekiq::Worker
256
- sidekiq_options unique: :until_and_while_executing, unique_args: :unique_args
290
+ sidekiq_options lock: :until_and_while_executing, unique_args: :unique_args
257
291
 
258
292
  def self.unique_args(args)
259
293
  if Sidekiq::ProcessSet.new.size > 1
@@ -277,7 +311,7 @@ If you need to perform any additional work after the lock has been released you
277
311
  ```ruby
278
312
  class UniqueJobWithFilterMethod
279
313
  include Sidekiq::Worker
280
- sidekiq_options unique: :while_executing,
314
+ sidekiq_options lock: :while_executing,
281
315
 
282
316
  def after_unlock
283
317
  # block has yielded and lock is released
@@ -293,7 +327,7 @@ To see logging in sidekiq when duplicate payload has been filtered out you can e
293
327
  ```ruby
294
328
  class UniqueJobWithFilterMethod
295
329
  include Sidekiq::Worker
296
- sidekiq_options unique: :while_executing,
330
+ sidekiq_options lock: :while_executing,
297
331
  log_duplicate_payload: true
298
332
 
299
333
  ...
@@ -305,21 +339,29 @@ end
305
339
 
306
340
  There are two ways to display and remove keys regarding uniqueness. The console way and the command line way.
307
341
 
308
- ### Console
342
+ ### Sidekiq Web
343
+
344
+ To use the web extension you need to require it in your routes.
345
+
346
+ ```ruby
347
+ # app/config/routes.rb
348
+ require 'sidekiq-unique-jobs/web'
349
+ mount Sidekiq::Web, at: '/sidekiq'
350
+ ```
309
351
 
310
- Start the console with the following command `bundle exec uniquejobs console`.
352
+ There is no need to `require 'sidekiq/web'` since `sidekiq_unique_jobs/web`
353
+ already does this.
311
354
 
312
- #### List Unique Keys
355
+ To filter/search for keys we can use the wildcard `*`. If we have a unique digest `'uniquejobs:9e9b5ce5d423d3ea470977004b50ff84` we can search for it by enter `*ff84` and it should return all digests that end with `ff84`.
313
356
 
314
- `keys '*', 100`
315
357
 
316
- #### Remove Unique Keys
358
+ #### Show Unique Digests
317
359
 
318
- `del '*', 100, false` the dry_run and count parameters are both required. This is to have some type of protection against clearing out all uniqueness.
360
+ ![Unique Digests](assets/unique_digests_1.png)
319
361
 
320
- ### Command Line
362
+ #### Show keys for digest
321
363
 
322
- `bundle exec uniquejobs` displays help on how to use the unique jobs command line.
364
+ ![Unique Digests](assets/unique_digests_2.png)
323
365
 
324
366
  ## Communication
325
367
 
Binary file
Binary file
@@ -4,8 +4,10 @@
4
4
 
5
5
  class AnotherUniqueJob
6
6
  include Sidekiq::Worker
7
- sidekiq_options queue: :working2, retry: 1, backtrace: 10,
8
- unique: :until_executed
7
+ sidekiq_options backtrace: 10,
8
+ lock: :until_executed,
9
+ queue: :working2,
10
+ retry: 1
9
11
 
10
12
  def perform(args)
11
13
  args
@@ -5,7 +5,7 @@
5
5
  require_relative 'custom_queue_job'
6
6
 
7
7
  class CustomQueueJobWithFilterMethod < CustomQueueJob
8
- sidekiq_options unique: :until_executed, unique_args: :args_filter
8
+ sidekiq_options lock: :until_executed, unique_args: :args_filter
9
9
 
10
10
  def self.args_filter(args)
11
11
  args.first
@@ -7,7 +7,7 @@ require_relative './custom_queue_job'
7
7
  class CustomQueueJobWithFilterProc < CustomQueueJob
8
8
  # slightly contrived example of munging args to the
9
9
  # worker and removing a random bit.
10
- sidekiq_options unique: :until_expired,
10
+ sidekiq_options lock: :until_expired,
11
11
  unique_args: (lambda do |args|
12
12
  options = args.extract_options!
13
13
  options.delete('random')
@@ -4,7 +4,7 @@
4
4
 
5
5
  class ExpiringJob
6
6
  include Sidekiq::Worker
7
- sidekiq_options unique: :until_executed, lock_expiration: 10 * 60
7
+ sidekiq_options lock: :until_executed, lock_expiration: 10 * 60
8
8
 
9
9
  def perform(one, two)
10
10
  [one, two]
@@ -4,7 +4,7 @@
4
4
 
5
5
  class InlineWorker
6
6
  include Sidekiq::Worker
7
- sidekiq_options unique: :while_executing, lock_timeout: 5
7
+ sidekiq_options lock: :while_executing, lock_timeout: 5
8
8
 
9
9
  def perform(one)
10
10
  TestClass.run(one)