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.
- checksums.yaml +4 -4
- data/.codeclimate.yml +6 -7
- data/.github/ISSUE_TEMPLATE/bug_report.md +1 -1
- data/.reek.yml +17 -48
- data/.rubocop.yml +3 -0
- data/.yardopts +7 -0
- data/CHANGELOG.md +2 -0
- data/README.md +65 -23
- data/assets/unique_digests_1.png +0 -0
- data/assets/unique_digests_2.png +0 -0
- data/examples/another_unique_job.rb +4 -2
- data/examples/custom_queue_job_with_filter_method.rb +1 -1
- data/examples/custom_queue_job_with_filter_proc.rb +1 -1
- data/examples/expiring_job.rb +1 -1
- data/examples/inline_worker.rb +1 -1
- data/examples/just_a_worker.rb +1 -1
- data/examples/long_running_job.rb +4 -2
- data/examples/main_job.rb +3 -2
- data/examples/my_unique_job.rb +4 -5
- data/examples/my_unique_job_with_filter_method.rb +3 -3
- data/examples/my_unique_job_with_filter_proc.rb +3 -3
- data/examples/notify_worker.rb +2 -2
- data/examples/simple_worker.rb +2 -2
- data/examples/unique_across_workers_job.rb +1 -1
- data/examples/unique_job_on_conflict_raise.rb +14 -0
- data/examples/unique_job_on_conflict_reject.rb +14 -0
- data/examples/unique_job_on_conflict_reschedule.rb +14 -0
- data/examples/unique_job_with_conditional_parameter.rb +3 -3
- data/examples/unique_job_with_filter_method.rb +5 -2
- data/examples/unique_job_with_nil_unique_args.rb +3 -3
- data/examples/unique_job_with_no_unique_args_method.rb +3 -3
- data/examples/unique_job_withthout_unique_args_parameter.rb +3 -3
- data/examples/unique_on_all_queues_job.rb +1 -1
- data/examples/until_and_while_executing_job.rb +4 -1
- data/examples/until_executed_2_job.rb +5 -5
- data/examples/until_executed_job.rb +5 -5
- data/examples/until_executing_job.rb +1 -1
- data/examples/until_expired_job.rb +1 -1
- data/examples/until_global_expired_job.rb +1 -1
- data/examples/while_executing_job.rb +2 -2
- data/examples/while_executing_reject_job.rb +2 -2
- data/examples/without_argument_job.rb +1 -1
- data/lib/sidekiq_unique_jobs.rb +30 -0
- data/lib/sidekiq_unique_jobs/client/middleware.rb +12 -1
- data/lib/sidekiq_unique_jobs/connection.rb +5 -1
- data/lib/sidekiq_unique_jobs/constants.rb +3 -0
- data/lib/sidekiq_unique_jobs/digests.rb +111 -0
- data/lib/sidekiq_unique_jobs/exceptions.rb +15 -16
- data/lib/sidekiq_unique_jobs/lock/base_lock.rb +44 -3
- data/lib/sidekiq_unique_jobs/lock/until_and_while_executing.rb +13 -3
- data/lib/sidekiq_unique_jobs/lock/until_executed.rb +8 -1
- data/lib/sidekiq_unique_jobs/lock/until_executing.rb +8 -1
- data/lib/sidekiq_unique_jobs/lock/until_expired.rb +14 -2
- data/lib/sidekiq_unique_jobs/lock/while_executing.rb +19 -5
- data/lib/sidekiq_unique_jobs/lock/while_executing_reject.rb +16 -63
- data/lib/sidekiq_unique_jobs/locksmith.rb +36 -13
- data/lib/sidekiq_unique_jobs/logging.rb +24 -1
- data/lib/sidekiq_unique_jobs/normalizer.rb +6 -0
- data/lib/sidekiq_unique_jobs/on_conflict.rb +24 -0
- data/lib/sidekiq_unique_jobs/on_conflict/log.rb +20 -0
- data/lib/sidekiq_unique_jobs/on_conflict/null_strategy.rb +16 -0
- data/lib/sidekiq_unique_jobs/on_conflict/raise.rb +17 -0
- data/lib/sidekiq_unique_jobs/on_conflict/reject.rb +72 -0
- data/lib/sidekiq_unique_jobs/on_conflict/reschedule.rb +24 -0
- data/lib/sidekiq_unique_jobs/on_conflict/strategy.rb +28 -0
- data/lib/sidekiq_unique_jobs/options_with_fallback.rb +19 -4
- data/lib/sidekiq_unique_jobs/scripts.rb +31 -0
- data/lib/sidekiq_unique_jobs/server/middleware.rb +10 -0
- data/lib/sidekiq_unique_jobs/sidekiq_worker_methods.rb +15 -1
- data/lib/sidekiq_unique_jobs/timeout/calculator.rb +17 -4
- data/lib/sidekiq_unique_jobs/unique_args.rb +47 -5
- data/lib/sidekiq_unique_jobs/unlockable.rb +10 -0
- data/lib/sidekiq_unique_jobs/util.rb +12 -7
- data/lib/sidekiq_unique_jobs/version.rb +1 -1
- data/lib/sidekiq_unique_jobs/web.rb +51 -0
- data/lib/sidekiq_unique_jobs/web/helpers.rb +37 -0
- data/lib/sidekiq_unique_jobs/web/views/unique_digest.erb +28 -0
- data/lib/sidekiq_unique_jobs/web/views/unique_digests.erb +42 -0
- data/redis/create.lua +4 -2
- data/redis/delete.lua +3 -1
- data/redis/delete_by_digest.lua +22 -0
- data/redis/signal.lua +3 -1
- data/sidekiq-unique-jobs.gemspec +2 -0
- metadata +49 -3
- 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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c90e3f7dec1b958a7516b7fe9aa703622abba4e7713c1e18d3022c6f853822b2
|
4
|
+
data.tar.gz: b3597746d75ce16841f2dc91bd5ba1377850f1341e4bece3478f803f61840979
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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-
|
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
|
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
|
-
-
|
16
|
-
-
|
17
|
-
- SidekiqUniqueJobs::
|
18
|
-
- SidekiqUniqueJobs
|
19
|
-
-
|
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::
|
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::
|
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
data/.yardopts
ADDED
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
|
-
* [
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
-
###
|
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
|
-
|
352
|
+
There is no need to `require 'sidekiq/web'` since `sidekiq_unique_jobs/web`
|
353
|
+
already does this.
|
311
354
|
|
312
|
-
|
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
|
-
####
|
358
|
+
#### Show Unique Digests
|
317
359
|
|
318
|
-
|
360
|
+
![Unique Digests](assets/unique_digests_1.png)
|
319
361
|
|
320
|
-
|
362
|
+
#### Show keys for digest
|
321
363
|
|
322
|
-
|
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
|
8
|
-
|
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
|
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
|
10
|
+
sidekiq_options lock: :until_expired,
|
11
11
|
unique_args: (lambda do |args|
|
12
12
|
options = args.extract_options!
|
13
13
|
options.delete('random')
|
data/examples/expiring_job.rb
CHANGED