sidekiq-unique-jobs 7.0.0.beta21 → 7.0.0.beta26
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/CHANGELOG.md +99 -3
- data/README.md +48 -23
- data/lib/sidekiq_unique_jobs.rb +0 -1
- data/lib/sidekiq_unique_jobs/batch_delete.rb +1 -1
- data/lib/sidekiq_unique_jobs/changelog.rb +1 -1
- data/lib/sidekiq_unique_jobs/cli.rb +4 -2
- data/lib/sidekiq_unique_jobs/connection.rb +1 -1
- data/lib/sidekiq_unique_jobs/constants.rb +2 -1
- data/lib/sidekiq_unique_jobs/digests.rb +1 -1
- data/lib/sidekiq_unique_jobs/exceptions.rb +9 -9
- data/lib/sidekiq_unique_jobs/job.rb +5 -5
- data/lib/sidekiq_unique_jobs/json.rb +1 -1
- data/lib/sidekiq_unique_jobs/key.rb +1 -1
- data/lib/sidekiq_unique_jobs/lock.rb +1 -1
- data/lib/sidekiq_unique_jobs/lock/base_lock.rb +1 -1
- data/lib/sidekiq_unique_jobs/lock/client_validator.rb +1 -1
- data/lib/sidekiq_unique_jobs/lock/server_validator.rb +1 -1
- data/lib/sidekiq_unique_jobs/lock/until_and_while_executing.rb +1 -1
- data/lib/sidekiq_unique_jobs/lock/until_executed.rb +1 -1
- data/lib/sidekiq_unique_jobs/lock/until_executing.rb +1 -1
- data/lib/sidekiq_unique_jobs/lock/until_expired.rb +1 -1
- data/lib/sidekiq_unique_jobs/lock/validator.rb +1 -1
- data/lib/sidekiq_unique_jobs/lock/while_executing.rb +1 -1
- data/lib/sidekiq_unique_jobs/lock/while_executing_reject.rb +1 -1
- data/lib/sidekiq_unique_jobs/lock_args.rb +2 -2
- data/lib/sidekiq_unique_jobs/lock_config.rb +5 -5
- data/lib/sidekiq_unique_jobs/lock_digest.rb +2 -2
- data/lib/sidekiq_unique_jobs/lock_info.rb +1 -1
- data/lib/sidekiq_unique_jobs/lock_timeout.rb +1 -1
- data/lib/sidekiq_unique_jobs/lock_ttl.rb +1 -1
- data/lib/sidekiq_unique_jobs/locksmith.rb +1 -1
- data/lib/sidekiq_unique_jobs/logging.rb +3 -3
- data/lib/sidekiq_unique_jobs/logging/middleware_context.rb +2 -2
- data/lib/sidekiq_unique_jobs/lua/reap_orphans.lua +1 -5
- data/lib/sidekiq_unique_jobs/lua/shared/_delete_from_queue.lua +3 -0
- data/lib/sidekiq_unique_jobs/lua/shared/_find_digest_in_process_set.lua +16 -5
- data/lib/sidekiq_unique_jobs/middleware.rb +16 -4
- data/lib/sidekiq_unique_jobs/middleware/client.rb +5 -5
- data/lib/sidekiq_unique_jobs/middleware/server.rb +3 -3
- data/lib/sidekiq_unique_jobs/normalizer.rb +1 -1
- data/lib/sidekiq_unique_jobs/on_conflict.rb +1 -1
- data/lib/sidekiq_unique_jobs/on_conflict/log.rb +1 -1
- data/lib/sidekiq_unique_jobs/on_conflict/null_strategy.rb +1 -1
- data/lib/sidekiq_unique_jobs/on_conflict/raise.rb +1 -1
- data/lib/sidekiq_unique_jobs/on_conflict/reject.rb +2 -2
- data/lib/sidekiq_unique_jobs/on_conflict/replace.rb +1 -1
- data/lib/sidekiq_unique_jobs/on_conflict/reschedule.rb +1 -1
- data/lib/sidekiq_unique_jobs/on_conflict/strategy.rb +1 -1
- data/lib/sidekiq_unique_jobs/options_with_fallback.rb +1 -1
- data/lib/sidekiq_unique_jobs/orphans/lua_reaper.rb +1 -1
- data/lib/sidekiq_unique_jobs/orphans/manager.rb +35 -4
- data/lib/sidekiq_unique_jobs/orphans/null_reaper.rb +24 -0
- data/lib/sidekiq_unique_jobs/orphans/observer.rb +2 -2
- data/lib/sidekiq_unique_jobs/orphans/reaper.rb +5 -1
- data/lib/sidekiq_unique_jobs/orphans/ruby_reaper.rb +18 -11
- data/lib/sidekiq_unique_jobs/profiler.rb +1 -1
- data/lib/sidekiq_unique_jobs/redis.rb +1 -1
- data/lib/sidekiq_unique_jobs/redis/entity.rb +1 -1
- data/lib/sidekiq_unique_jobs/redis/hash.rb +1 -1
- data/lib/sidekiq_unique_jobs/redis/list.rb +1 -1
- data/lib/sidekiq_unique_jobs/redis/set.rb +1 -1
- data/lib/sidekiq_unique_jobs/redis/sorted_set.rb +1 -1
- data/lib/sidekiq_unique_jobs/redis/string.rb +1 -1
- data/lib/sidekiq_unique_jobs/rspec/matchers.rb +2 -2
- data/lib/sidekiq_unique_jobs/rspec/matchers/have_valid_sidekiq_options.rb +2 -2
- data/lib/sidekiq_unique_jobs/script.rb +1 -1
- data/lib/sidekiq_unique_jobs/script/caller.rb +2 -2
- data/lib/sidekiq_unique_jobs/sidekiq_unique_ext.rb +5 -5
- data/lib/sidekiq_unique_jobs/sidekiq_unique_jobs.rb +1 -1
- data/lib/sidekiq_unique_jobs/sidekiq_worker_methods.rb +8 -2
- data/lib/sidekiq_unique_jobs/timing.rb +1 -1
- data/lib/sidekiq_unique_jobs/unlockable.rb +1 -1
- data/lib/sidekiq_unique_jobs/update_version.rb +1 -1
- data/lib/sidekiq_unique_jobs/upgrade_locks.rb +1 -1
- data/lib/sidekiq_unique_jobs/version.rb +1 -1
- data/lib/sidekiq_unique_jobs/version_check.rb +23 -4
- data/lib/sidekiq_unique_jobs/web.rb +1 -1
- data/lib/sidekiq_unique_jobs/web/helpers.rb +1 -1
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b8af7c3fd6c11e4c8f0b1c5cb9978a044f85d1af36515913a645575031e89af2
|
4
|
+
data.tar.gz: b2347d8d8aad7e923777dedcfa8fcea51e78f3eeb07dada968da5d858b34dcc6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e879321a4c43dafc44de739bde2fa16b70d8c84d9062c99b99714b50068498619c4a82f87da53c9ccee809de1e9b61a318a04000d796090800633ce304b92135
|
7
|
+
data.tar.gz: c589a5c8dc2bcf304b52e21f44aff31c806a5941037e4db4dfc8f7041c114caac5ada9d898b3e245e4a870b2f585943ca4a4842dca4517ff867b2fa053273940
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,98 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [Unreleased](https://github.com/mhenrixon/sidekiq-unique-jobs/tree/HEAD)
|
4
|
+
|
5
|
+
[Full Changelog](https://github.com/mhenrixon/sidekiq-unique-jobs/compare/v6.0.25...HEAD)
|
6
|
+
|
7
|
+
**Merged pull requests:**
|
8
|
+
|
9
|
+
- Update sidekiq-unique-jobs.gemspec [\#542](https://github.com/mhenrixon/sidekiq-unique-jobs/pull/542) ([sergey-alekseev](https://github.com/sergey-alekseev))
|
10
|
+
|
11
|
+
## [v6.0.25](https://github.com/mhenrixon/sidekiq-unique-jobs/tree/v6.0.25) (2020-10-26)
|
12
|
+
|
13
|
+
[Full Changelog](https://github.com/mhenrixon/sidekiq-unique-jobs/compare/v7.0.0.beta25...v6.0.25)
|
14
|
+
|
15
|
+
**Implemented enhancements:**
|
16
|
+
|
17
|
+
- Support apartment [\#541](https://github.com/mhenrixon/sidekiq-unique-jobs/pull/541) ([mhenrixon](https://github.com/mhenrixon))
|
18
|
+
- Support both instance method and class method [\#528](https://github.com/mhenrixon/sidekiq-unique-jobs/pull/528) ([mhenrixon](https://github.com/mhenrixon))
|
19
|
+
|
20
|
+
## [v7.0.0.beta25](https://github.com/mhenrixon/sidekiq-unique-jobs/tree/v7.0.0.beta25) (2020-10-26)
|
21
|
+
|
22
|
+
[Full Changelog](https://github.com/mhenrixon/sidekiq-unique-jobs/compare/v7.0.0.beta24...v7.0.0.beta25)
|
23
|
+
|
24
|
+
**Implemented enhancements:**
|
25
|
+
|
26
|
+
- Bump rubocop [\#539](https://github.com/mhenrixon/sidekiq-unique-jobs/pull/539) ([mhenrixon](https://github.com/mhenrixon))
|
27
|
+
|
28
|
+
**Fixed bugs:**
|
29
|
+
|
30
|
+
- Ruby reaper not working, active jobs queried incorrectly [\#537](https://github.com/mhenrixon/sidekiq-unique-jobs/issues/537)
|
31
|
+
- Fix RubyReaper active? [\#538](https://github.com/mhenrixon/sidekiq-unique-jobs/pull/538) ([tanner-rutgers](https://github.com/tanner-rutgers))
|
32
|
+
|
33
|
+
**Closed issues:**
|
34
|
+
|
35
|
+
- ConnectionPool::TimeoutError and :until\_executed [\#535](https://github.com/mhenrixon/sidekiq-unique-jobs/issues/535)
|
36
|
+
|
37
|
+
**Merged pull requests:**
|
38
|
+
|
39
|
+
- Support apartment [\#540](https://github.com/mhenrixon/sidekiq-unique-jobs/pull/540) ([mhenrixon](https://github.com/mhenrixon))
|
40
|
+
|
41
|
+
## [v7.0.0.beta24](https://github.com/mhenrixon/sidekiq-unique-jobs/tree/v7.0.0.beta24) (2020-09-27)
|
42
|
+
|
43
|
+
[Full Changelog](https://github.com/mhenrixon/sidekiq-unique-jobs/compare/v7.0.0.beta23...v7.0.0.beta24)
|
44
|
+
|
45
|
+
**Implemented enhancements:**
|
46
|
+
|
47
|
+
- Support both instance method and class method [\#527](https://github.com/mhenrixon/sidekiq-unique-jobs/pull/527) ([mhenrixon](https://github.com/mhenrixon))
|
48
|
+
|
49
|
+
**Closed issues:**
|
50
|
+
|
51
|
+
- Leaked keys in version 5.0.10 [\#519](https://github.com/mhenrixon/sidekiq-unique-jobs/issues/519)
|
52
|
+
|
53
|
+
## [v7.0.0.beta23](https://github.com/mhenrixon/sidekiq-unique-jobs/tree/v7.0.0.beta23) (2020-06-23)
|
54
|
+
|
55
|
+
[Full Changelog](https://github.com/mhenrixon/sidekiq-unique-jobs/compare/v6.0.23...v7.0.0.beta23)
|
56
|
+
|
57
|
+
**Fixed bugs:**
|
58
|
+
|
59
|
+
- Exit early when no results are returned from LRANGE given jobs might already processed [\#521](https://github.com/mhenrixon/sidekiq-unique-jobs/pull/521) ([vipulnsward](https://github.com/vipulnsward))
|
60
|
+
|
61
|
+
## [v6.0.23](https://github.com/mhenrixon/sidekiq-unique-jobs/tree/v6.0.23) (2020-06-23)
|
62
|
+
|
63
|
+
[Full Changelog](https://github.com/mhenrixon/sidekiq-unique-jobs/compare/v7.0.0.beta22...v6.0.23)
|
64
|
+
|
65
|
+
**Fixed bugs:**
|
66
|
+
|
67
|
+
- Ruby reaper incorrectly checks active jobs — removes every active lock as result [\#517](https://github.com/mhenrixon/sidekiq-unique-jobs/issues/517)
|
68
|
+
- Backport \#465 to 6.x series [\#520](https://github.com/mhenrixon/sidekiq-unique-jobs/pull/520) ([replaid](https://github.com/replaid))
|
69
|
+
|
70
|
+
## [v7.0.0.beta22](https://github.com/mhenrixon/sidekiq-unique-jobs/tree/v7.0.0.beta22) (2020-06-12)
|
71
|
+
|
72
|
+
[Full Changelog](https://github.com/mhenrixon/sidekiq-unique-jobs/compare/v7.0.0.beta21...v7.0.0.beta22)
|
73
|
+
|
74
|
+
**Fixed bugs:**
|
75
|
+
|
76
|
+
- Infinite loop in ruby reaper [\#515](https://github.com/mhenrixon/sidekiq-unique-jobs/issues/515)
|
77
|
+
- Prevent reaping of active jobs [\#518](https://github.com/mhenrixon/sidekiq-unique-jobs/pull/518) ([mhenrixon](https://github.com/mhenrixon))
|
78
|
+
|
79
|
+
## [v7.0.0.beta21](https://github.com/mhenrixon/sidekiq-unique-jobs/tree/v7.0.0.beta21) (2020-06-12)
|
80
|
+
|
81
|
+
[Full Changelog](https://github.com/mhenrixon/sidekiq-unique-jobs/compare/v7.0.0.beta20...v7.0.0.beta21)
|
82
|
+
|
83
|
+
**Implemented enhancements:**
|
84
|
+
|
85
|
+
- Move gems to gemfile [\#513](https://github.com/mhenrixon/sidekiq-unique-jobs/pull/513) ([mhenrixon](https://github.com/mhenrixon))
|
86
|
+
- Move dev-gems from gemspec to gemfile [\#512](https://github.com/mhenrixon/sidekiq-unique-jobs/pull/512) ([mhenrixon](https://github.com/mhenrixon))
|
87
|
+
|
88
|
+
**Fixed bugs:**
|
89
|
+
|
90
|
+
- Prevent indefinitely looping entries [\#516](https://github.com/mhenrixon/sidekiq-unique-jobs/pull/516) ([mhenrixon](https://github.com/mhenrixon))
|
91
|
+
|
92
|
+
**Closed issues:**
|
93
|
+
|
94
|
+
- Missing web interface [\#514](https://github.com/mhenrixon/sidekiq-unique-jobs/issues/514)
|
95
|
+
|
3
96
|
## [v7.0.0.beta20](https://github.com/mhenrixon/sidekiq-unique-jobs/tree/v7.0.0.beta20) (2020-06-02)
|
4
97
|
|
5
98
|
[Full Changelog](https://github.com/mhenrixon/sidekiq-unique-jobs/compare/v7.0.0.beta19...v7.0.0.beta20)
|
@@ -36,13 +129,16 @@
|
|
36
129
|
|
37
130
|
- Try GitHub actions [\#505](https://github.com/mhenrixon/sidekiq-unique-jobs/pull/505) ([mhenrixon](https://github.com/mhenrixon))
|
38
131
|
|
132
|
+
**Fixed bugs:**
|
133
|
+
|
134
|
+
- Deep stringify worker options to account for hash in on\_conflict [\#506](https://github.com/mhenrixon/sidekiq-unique-jobs/pull/506) ([jasonbekolay](https://github.com/jasonbekolay))
|
135
|
+
|
39
136
|
## [v7.0.0.beta16](https://github.com/mhenrixon/sidekiq-unique-jobs/tree/v7.0.0.beta16) (2020-05-19)
|
40
137
|
|
41
138
|
[Full Changelog](https://github.com/mhenrixon/sidekiq-unique-jobs/compare/v6.0.22...v7.0.0.beta16)
|
42
139
|
|
43
140
|
**Fixed bugs:**
|
44
141
|
|
45
|
-
- Deep stringify worker options to account for hash in on\_conflict [\#506](https://github.com/mhenrixon/sidekiq-unique-jobs/pull/506) ([jasonbekolay](https://github.com/jasonbekolay))
|
46
142
|
- Deprecate configuration options with `default\_` [\#504](https://github.com/mhenrixon/sidekiq-unique-jobs/pull/504) ([mhenrixon](https://github.com/mhenrixon))
|
47
143
|
- Fix access to both server and client conflict [\#503](https://github.com/mhenrixon/sidekiq-unique-jobs/pull/503) ([mhenrixon](https://github.com/mhenrixon))
|
48
144
|
|
@@ -380,7 +476,7 @@
|
|
380
476
|
**Closed issues:**
|
381
477
|
|
382
478
|
- Unique args in combination with sidekiq cron contains `\_aj\_symbol\_keys` [\#363](https://github.com/mhenrixon/sidekiq-unique-jobs/issues/363)
|
383
|
-
- Low quality
|
479
|
+
- Low quality piece of shit [\#360](https://github.com/mhenrixon/sidekiq-unique-jobs/issues/360)
|
384
480
|
- Passthrough has been deprecated and will be removed in redis-namespace 2.0 [\#338](https://github.com/mhenrixon/sidekiq-unique-jobs/issues/338)
|
385
481
|
|
386
482
|
## [v6.0.12](https://github.com/mhenrixon/sidekiq-unique-jobs/tree/v6.0.12) (2019-02-28)
|
@@ -1243,7 +1339,6 @@
|
|
1243
1339
|
- Clarify README about unique expiration [\#36](https://github.com/mhenrixon/sidekiq-unique-jobs/pull/36) ([spacemunkay](https://github.com/spacemunkay))
|
1244
1340
|
- Add option to make jobs unique on all queues [\#32](https://github.com/mhenrixon/sidekiq-unique-jobs/pull/32) ([robinmessage](https://github.com/robinmessage))
|
1245
1341
|
- Fix homepage in gemspec [\#29](https://github.com/mhenrixon/sidekiq-unique-jobs/pull/29) ([tmaier](https://github.com/tmaier))
|
1246
|
-
- Compatibility with Sidekiq 2.12.1 Scheduled Jobs [\#16](https://github.com/mhenrixon/sidekiq-unique-jobs/pull/16) ([lsimoneau](https://github.com/lsimoneau))
|
1247
1342
|
|
1248
1343
|
## [v2.7.0](https://github.com/mhenrixon/sidekiq-unique-jobs/tree/v2.7.0) (2013-11-24)
|
1249
1344
|
|
@@ -1262,6 +1357,7 @@
|
|
1262
1357
|
- Make unlock/yield order configurable. [\#21](https://github.com/mhenrixon/sidekiq-unique-jobs/pull/21) ([endofunky](https://github.com/endofunky))
|
1263
1358
|
- Rely on Sidekiq's String\#constantize extension instead of rolling our own [\#19](https://github.com/mhenrixon/sidekiq-unique-jobs/pull/19) ([disbelief](https://github.com/disbelief))
|
1264
1359
|
- Attempt to constantize String `worker\_class` arguments passed to client middleware [\#17](https://github.com/mhenrixon/sidekiq-unique-jobs/pull/17) ([disbelief](https://github.com/disbelief))
|
1360
|
+
- Compatibility with Sidekiq 2.12.1 Scheduled Jobs [\#16](https://github.com/mhenrixon/sidekiq-unique-jobs/pull/16) ([lsimoneau](https://github.com/lsimoneau))
|
1265
1361
|
- Allow worker to specify which arguments to include in uniquing hash [\#12](https://github.com/mhenrixon/sidekiq-unique-jobs/pull/12) ([sax](https://github.com/sax))
|
1266
1362
|
- Add support for unique when using Sidekiq's delay function [\#11](https://github.com/mhenrixon/sidekiq-unique-jobs/pull/11) ([eduardosasso](https://github.com/eduardosasso))
|
1267
1363
|
- Adding the unique prefix option [\#8](https://github.com/mhenrixon/sidekiq-unique-jobs/pull/8) ([KensoDev](https://github.com/KensoDev))
|
data/README.md
CHANGED
@@ -33,15 +33,27 @@
|
|
33
33
|
- [While Executing](#while-executing)
|
34
34
|
- [Custom Locks](#custom-locks)
|
35
35
|
- [Conflict Strategy](#conflict-strategy)
|
36
|
-
- [
|
37
|
-
- [
|
38
|
-
- [
|
39
|
-
- [
|
40
|
-
- [
|
41
|
-
- [
|
42
|
-
- [
|
43
|
-
- [
|
44
|
-
- [
|
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)
|
45
57
|
- [Contributing](#contributing)
|
46
58
|
- [Contributors](#contributors)
|
47
59
|
|
@@ -106,6 +118,8 @@ See [Locking & Unlocking](https://github.com/mhenrixon/sidekiq-unique-jobs/wiki/
|
|
106
118
|
|
107
119
|
The gem supports a few different configuration options that might be of interest if you run into some weird issues.
|
108
120
|
|
121
|
+
Configure SidekiqUniqueJobs in an initializer or the sidekiq initializer on application startup.
|
122
|
+
|
109
123
|
```ruby
|
110
124
|
SidekiqUniqueJobs.configure do |config|
|
111
125
|
config.debug_lua = true
|
@@ -189,6 +203,14 @@ On the other hand if I increase it to 10 000 orphaned locks per cleanup (`reaper
|
|
189
203
|
|
190
204
|
> BUSY Redis is busy running a script. You can only call SCRIPT KILL or SHUTDOWN NOSAVE. (Redis::CommandError)
|
191
205
|
|
206
|
+
If you want to disable the reaper set it to `:none`, `nil` or `false`. Actually, any value that isn't `:ruby` or `:lua` will disable the reaping.
|
207
|
+
|
208
|
+
```ruby
|
209
|
+
SidekiqUniqueJobs.config.reaper = :none
|
210
|
+
SidekiqUniqueJobs.config.reaper = nil
|
211
|
+
SidekiqUniqueJobs.config.reaper = false
|
212
|
+
```
|
213
|
+
|
192
214
|
### reaper_count
|
193
215
|
|
194
216
|
```ruby
|
@@ -383,11 +405,9 @@ You can refer on all the locks defined in `lib/sidekiq_unique_jobs/lock/*.rb`.
|
|
383
405
|
|
384
406
|
In order to make it available, you should call in your project startup:
|
385
407
|
|
386
|
-
|
387
|
-
# For rails application
|
388
|
-
# config/initializers/sidekiq_unique_jobs.rb
|
389
|
-
# For other projects, whenever you prefer
|
408
|
+
(For rails application config/initializers/sidekiq_unique_jobs.rb or other projects, wherever you prefer)
|
390
409
|
|
410
|
+
```ruby
|
391
411
|
SidekiqUniqueJobs.configure do |config|
|
392
412
|
config.add_lock :my_custom_lock, Locks::MyCustomLock
|
393
413
|
end
|
@@ -408,7 +428,9 @@ The last one is log which can be be used with the lock `UntilExecuted` and `Unti
|
|
408
428
|
It is possible for locks to have different conflict strategy for the client and server. This is useful for `:until_and_while_executing`.
|
409
429
|
|
410
430
|
```ruby
|
411
|
-
sidekiq_options lock: :until_and_while_executing,
|
431
|
+
sidekiq_options lock: :until_and_while_executing,
|
432
|
+
on_conflict: { client: :log, server: :reject }
|
433
|
+
```
|
412
434
|
|
413
435
|
### log
|
414
436
|
|
@@ -474,11 +496,9 @@ You can refer to all the strategies defined in `lib/sidekiq_unique_jobs/on_confl
|
|
474
496
|
|
475
497
|
In order to make it available, you should call in your project startup:
|
476
498
|
|
477
|
-
|
478
|
-
# For rails application
|
479
|
-
# config/initializers/sidekiq_unique_jobs.rb
|
480
|
-
# For other projects, whenever you prefer
|
499
|
+
(For rails application config/initializers/sidekiq_unique_jobs.rb for other projects, wherever you prefer)
|
481
500
|
|
501
|
+
```ruby
|
482
502
|
SidekiqUniqueJobs.configure do |config|
|
483
503
|
config.add_strategy :my_custom_strategy, Strategies::MyCustomStrategy
|
484
504
|
end
|
@@ -562,11 +582,17 @@ If you need to perform any additional work after the lock has been released you
|
|
562
582
|
**Exception 1:** UntilExecuting unlocks and uses callback before yielding.
|
563
583
|
**Exception 2:** UntilExpired expires eventually, no after_unlock hook is called.
|
564
584
|
|
585
|
+
**NOTE:** _It is also possible to write this code as a class method._
|
586
|
+
|
565
587
|
```ruby
|
566
588
|
class UniqueJobWithFilterMethod
|
567
589
|
include Sidekiq::Worker
|
568
590
|
sidekiq_options lock: :while_executing,
|
569
591
|
|
592
|
+
def self.after_unlock
|
593
|
+
# block has yielded and lock is released
|
594
|
+
end
|
595
|
+
|
570
596
|
def after_unlock
|
571
597
|
# block has yielded and lock is released
|
572
598
|
end
|
@@ -605,7 +631,6 @@ end
|
|
605
631
|
Starting in v5.1, Sidekiq can also fire a global callback when a job dies:
|
606
632
|
|
607
633
|
```ruby
|
608
|
-
# this goes in your initializer
|
609
634
|
Sidekiq.configure_server do |config|
|
610
635
|
config.death_handlers << ->(job, _ex) do
|
611
636
|
digest = job['unique_digest']
|
@@ -643,7 +668,7 @@ There are several ways of removing keys that are stuck. The prefered way is by u
|
|
643
668
|
To use the web extension you need to require it in your routes.
|
644
669
|
|
645
670
|
```ruby
|
646
|
-
#
|
671
|
+
#app/config/routes.rb
|
647
672
|
require 'sidekiq_unique_jobs/web'
|
648
673
|
mount Sidekiq::Web, at: '/sidekiq'
|
649
674
|
```
|
@@ -674,15 +699,15 @@ Since v7 it is possible to perform some simple validation against your workers s
|
|
674
699
|
Let's take a _bad_ worker:
|
675
700
|
|
676
701
|
```ruby
|
677
|
-
#
|
702
|
+
#app/workers/bad_worker.rb
|
678
703
|
class BadWorker
|
679
704
|
sidekiq_options lock: :while_executing, on_conflict: :replace
|
680
705
|
end
|
681
706
|
|
682
|
-
#
|
707
|
+
#spec/workers/bad_worker_spec.rb
|
683
708
|
|
684
709
|
require "sidekiq_unique_jobs/testing"
|
685
|
-
#
|
710
|
+
#OR
|
686
711
|
require "sidekiq_unique_jobs/rspec/matchers"
|
687
712
|
|
688
713
|
RSpec.describe BadWorker do
|
data/lib/sidekiq_unique_jobs.rb
CHANGED
@@ -26,7 +26,6 @@ require "sidekiq_unique_jobs/connection"
|
|
26
26
|
require "sidekiq_unique_jobs/exceptions"
|
27
27
|
require "sidekiq_unique_jobs/script"
|
28
28
|
require "sidekiq_unique_jobs/script/caller"
|
29
|
-
require "sidekiq_unique_jobs/json"
|
30
29
|
require "sidekiq_unique_jobs/normalizer"
|
31
30
|
require "sidekiq_unique_jobs/job"
|
32
31
|
require "sidekiq_unique_jobs/redis"
|
@@ -6,13 +6,15 @@ module SidekiqUniqueJobs
|
|
6
6
|
#
|
7
7
|
# Command line interface for unique jobs
|
8
8
|
#
|
9
|
-
# @author Mikael Henriksson <mikael@
|
9
|
+
# @author Mikael Henriksson <mikael@mhenrixon.com>
|
10
10
|
#
|
11
11
|
class Cli < Thor
|
12
12
|
# :nodoc:
|
13
|
-
|
13
|
+
# rubocop:disable Style/OptionalBooleanParameter
|
14
|
+
def self.banner(command, _namespace = nil, _subcommand = false) # rubocop:disable Style/OptionalBooleanParameter
|
14
15
|
"jobs #{@package_name} #{command.usage}" # rubocop:disable ThreadSafety/InstanceVariableInClassMethod
|
15
16
|
end
|
17
|
+
# rubocop:enable Style/OptionalBooleanParameter
|
16
18
|
|
17
19
|
desc "list PATTERN", "list all unique digests and their expiry time"
|
18
20
|
option :count, aliases: :c, type: :numeric, default: 1000, desc: "The max number of digests to return"
|
@@ -3,10 +3,11 @@
|
|
3
3
|
#
|
4
4
|
# Module with constants to avoid string duplication
|
5
5
|
#
|
6
|
-
# @author Mikael Henriksson <mikael@
|
6
|
+
# @author Mikael Henriksson <mikael@mhenrixon.com>
|
7
7
|
#
|
8
8
|
module SidekiqUniqueJobs
|
9
9
|
ARGS ||= "args"
|
10
|
+
APARTMENT ||= "apartment"
|
10
11
|
AT ||= "at"
|
11
12
|
CHANGELOGS ||= "uniquejobs:changelog"
|
12
13
|
CLASS ||= "class"
|
@@ -4,14 +4,14 @@ module SidekiqUniqueJobs
|
|
4
4
|
#
|
5
5
|
# Base class for all exceptions raised from the gem
|
6
6
|
#
|
7
|
-
# @author Mikael Henriksson <mikael@
|
7
|
+
# @author Mikael Henriksson <mikael@mhenrixon.com>
|
8
8
|
#
|
9
9
|
class UniqueJobsError < ::RuntimeError
|
10
10
|
end
|
11
11
|
|
12
12
|
# Error raised when a Lua script fails to execute
|
13
13
|
#
|
14
|
-
# @author Mikael Henriksson <mikael@
|
14
|
+
# @author Mikael Henriksson <mikael@mhenrixon.com>
|
15
15
|
class Conflict < UniqueJobsError
|
16
16
|
def initialize(item)
|
17
17
|
super("Item with the key: #{item[LOCK_DIGEST]} is already scheduled or processing")
|
@@ -21,7 +21,7 @@ module SidekiqUniqueJobs
|
|
21
21
|
#
|
22
22
|
# Error raised when trying to add a duplicate lock
|
23
23
|
#
|
24
|
-
# @author Mikael Henriksson <mikael@
|
24
|
+
# @author Mikael Henriksson <mikael@mhenrixon.com>
|
25
25
|
#
|
26
26
|
class DuplicateLock < UniqueJobsError
|
27
27
|
end
|
@@ -29,7 +29,7 @@ module SidekiqUniqueJobs
|
|
29
29
|
#
|
30
30
|
# Error raised when trying to add a duplicate stragegy
|
31
31
|
#
|
32
|
-
# @author Mikael Henriksson <mikael@
|
32
|
+
# @author Mikael Henriksson <mikael@mhenrixon.com>
|
33
33
|
#
|
34
34
|
class DuplicateStrategy < UniqueJobsError
|
35
35
|
end
|
@@ -37,7 +37,7 @@ module SidekiqUniqueJobs
|
|
37
37
|
#
|
38
38
|
# Error raised when an invalid argument is given
|
39
39
|
#
|
40
|
-
# @author Mikael Henriksson <mikael@
|
40
|
+
# @author Mikael Henriksson <mikael@mhenrixon.com>
|
41
41
|
#
|
42
42
|
class InvalidArgument < UniqueJobsError
|
43
43
|
end
|
@@ -45,7 +45,7 @@ module SidekiqUniqueJobs
|
|
45
45
|
#
|
46
46
|
# Raised when a workers configuration is invalid
|
47
47
|
#
|
48
|
-
# @author Mikael Henriksson <mikael@
|
48
|
+
# @author Mikael Henriksson <mikael@mhenrixon.com>
|
49
49
|
#
|
50
50
|
class InvalidWorker < UniqueJobsError
|
51
51
|
def initialize(lock_config)
|
@@ -58,7 +58,7 @@ module SidekiqUniqueJobs
|
|
58
58
|
|
59
59
|
# Error raised when a Lua script fails to execute
|
60
60
|
#
|
61
|
-
# @author Mikael Henriksson <mikael@
|
61
|
+
# @author Mikael Henriksson <mikael@mhenrixon.com>
|
62
62
|
class InvalidUniqueArguments < UniqueJobsError
|
63
63
|
def initialize(options)
|
64
64
|
given = options[:given]
|
@@ -79,7 +79,7 @@ module SidekiqUniqueJobs
|
|
79
79
|
#
|
80
80
|
# Raised when a workers configuration is invalid
|
81
81
|
#
|
82
|
-
# @author Mikael Henriksson <mikael@
|
82
|
+
# @author Mikael Henriksson <mikael@mhenrixon.com>
|
83
83
|
#
|
84
84
|
class NotUniqueWorker < UniqueJobsError
|
85
85
|
def initialize(options)
|
@@ -89,7 +89,7 @@ module SidekiqUniqueJobs
|
|
89
89
|
|
90
90
|
# Error raised from {OptionsWithFallback#lock_class}
|
91
91
|
#
|
92
|
-
# @author Mikael Henriksson <mikael@
|
92
|
+
# @author Mikael Henriksson <mikael@mhenrixon.com>
|
93
93
|
class UnknownLock < UniqueJobsError
|
94
94
|
end
|
95
95
|
end
|