sidekiq-unique-jobs 6.0.25 → 7.1.33

Sign up to get free protection for your applications and to get access to all the features.
Files changed (130) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +1157 -41
  3. data/README.md +825 -291
  4. data/lib/sidekiq_unique_jobs/batch_delete.rb +124 -0
  5. data/lib/sidekiq_unique_jobs/changelog.rb +78 -0
  6. data/lib/sidekiq_unique_jobs/cli.rb +57 -29
  7. data/lib/sidekiq_unique_jobs/config.rb +319 -0
  8. data/lib/sidekiq_unique_jobs/connection.rb +6 -5
  9. data/lib/sidekiq_unique_jobs/constants.rb +46 -25
  10. data/lib/sidekiq_unique_jobs/core_ext.rb +80 -0
  11. data/lib/sidekiq_unique_jobs/deprecation.rb +65 -0
  12. data/lib/sidekiq_unique_jobs/digests.rb +70 -102
  13. data/lib/sidekiq_unique_jobs/exceptions.rb +88 -12
  14. data/lib/sidekiq_unique_jobs/expiring_digests.rb +14 -0
  15. data/lib/sidekiq_unique_jobs/job.rb +46 -12
  16. data/lib/sidekiq_unique_jobs/json.rb +47 -0
  17. data/lib/sidekiq_unique_jobs/key.rb +98 -0
  18. data/lib/sidekiq_unique_jobs/lock/base_lock.rb +111 -82
  19. data/lib/sidekiq_unique_jobs/lock/client_validator.rb +28 -0
  20. data/lib/sidekiq_unique_jobs/lock/server_validator.rb +27 -0
  21. data/lib/sidekiq_unique_jobs/lock/until_and_while_executing.rb +40 -15
  22. data/lib/sidekiq_unique_jobs/lock/until_executed.rb +30 -7
  23. data/lib/sidekiq_unique_jobs/lock/until_executing.rb +26 -2
  24. data/lib/sidekiq_unique_jobs/lock/until_expired.rb +27 -15
  25. data/lib/sidekiq_unique_jobs/lock/validator.rb +96 -0
  26. data/lib/sidekiq_unique_jobs/lock/while_executing.rb +26 -12
  27. data/lib/sidekiq_unique_jobs/lock/while_executing_reject.rb +3 -3
  28. data/lib/sidekiq_unique_jobs/lock.rb +342 -0
  29. data/lib/sidekiq_unique_jobs/lock_args.rb +127 -0
  30. data/lib/sidekiq_unique_jobs/lock_config.rb +126 -0
  31. data/lib/sidekiq_unique_jobs/lock_digest.rb +79 -0
  32. data/lib/sidekiq_unique_jobs/lock_info.rb +68 -0
  33. data/lib/sidekiq_unique_jobs/lock_timeout.rb +62 -0
  34. data/lib/sidekiq_unique_jobs/lock_ttl.rb +77 -0
  35. data/lib/sidekiq_unique_jobs/lock_type.rb +37 -0
  36. data/lib/sidekiq_unique_jobs/locksmith.rb +305 -101
  37. data/lib/sidekiq_unique_jobs/logging/middleware_context.rb +44 -0
  38. data/lib/sidekiq_unique_jobs/logging.rb +202 -33
  39. data/lib/sidekiq_unique_jobs/lua/delete.lua +51 -0
  40. data/lib/sidekiq_unique_jobs/lua/delete_by_digest.lua +42 -0
  41. data/lib/sidekiq_unique_jobs/lua/delete_job_by_digest.lua +38 -0
  42. data/lib/sidekiq_unique_jobs/lua/find_digest_in_queues.lua +26 -0
  43. data/lib/sidekiq_unique_jobs/lua/lock.lua +99 -0
  44. data/lib/sidekiq_unique_jobs/lua/lock_until_expired.lua +92 -0
  45. data/lib/sidekiq_unique_jobs/lua/locked.lua +35 -0
  46. data/lib/sidekiq_unique_jobs/lua/queue.lua +87 -0
  47. data/lib/sidekiq_unique_jobs/lua/reap_orphans.lua +122 -0
  48. data/lib/sidekiq_unique_jobs/lua/shared/_common.lua +40 -0
  49. data/lib/sidekiq_unique_jobs/lua/shared/_current_time.lua +8 -0
  50. data/lib/sidekiq_unique_jobs/lua/shared/_delete_from_queue.lua +22 -0
  51. data/lib/sidekiq_unique_jobs/lua/shared/_delete_from_sorted_set.lua +18 -0
  52. data/lib/sidekiq_unique_jobs/lua/shared/_find_digest_in_process_set.lua +53 -0
  53. data/lib/sidekiq_unique_jobs/lua/shared/_find_digest_in_queues.lua +43 -0
  54. data/lib/sidekiq_unique_jobs/lua/shared/_find_digest_in_sorted_set.lua +24 -0
  55. data/lib/sidekiq_unique_jobs/lua/shared/_hgetall.lua +13 -0
  56. data/lib/sidekiq_unique_jobs/lua/shared/_upgrades.lua +3 -0
  57. data/lib/sidekiq_unique_jobs/lua/unlock.lua +107 -0
  58. data/lib/sidekiq_unique_jobs/lua/update_version.lua +40 -0
  59. data/lib/sidekiq_unique_jobs/lua/upgrade.lua +68 -0
  60. data/lib/sidekiq_unique_jobs/middleware/client.rb +42 -0
  61. data/lib/sidekiq_unique_jobs/middleware/server.rb +31 -0
  62. data/lib/sidekiq_unique_jobs/middleware.rb +29 -43
  63. data/lib/sidekiq_unique_jobs/normalizer.rb +4 -4
  64. data/lib/sidekiq_unique_jobs/on_conflict/log.rb +9 -5
  65. data/lib/sidekiq_unique_jobs/on_conflict/null_strategy.rb +1 -1
  66. data/lib/sidekiq_unique_jobs/on_conflict/raise.rb +1 -1
  67. data/lib/sidekiq_unique_jobs/on_conflict/reject.rb +63 -17
  68. data/lib/sidekiq_unique_jobs/on_conflict/replace.rb +54 -14
  69. data/lib/sidekiq_unique_jobs/on_conflict/reschedule.rb +16 -5
  70. data/lib/sidekiq_unique_jobs/on_conflict/strategy.rb +25 -6
  71. data/lib/sidekiq_unique_jobs/on_conflict.rb +23 -10
  72. data/lib/sidekiq_unique_jobs/options_with_fallback.rb +39 -36
  73. data/lib/sidekiq_unique_jobs/orphans/lua_reaper.rb +29 -0
  74. data/lib/sidekiq_unique_jobs/orphans/manager.rb +241 -0
  75. data/lib/sidekiq_unique_jobs/orphans/null_reaper.rb +24 -0
  76. data/lib/sidekiq_unique_jobs/orphans/observer.rb +42 -0
  77. data/lib/sidekiq_unique_jobs/orphans/reaper.rb +114 -0
  78. data/lib/sidekiq_unique_jobs/orphans/reaper_resurrector.rb +170 -0
  79. data/lib/sidekiq_unique_jobs/orphans/ruby_reaper.rb +298 -0
  80. data/lib/sidekiq_unique_jobs/redis/entity.rb +112 -0
  81. data/lib/sidekiq_unique_jobs/redis/hash.rb +56 -0
  82. data/lib/sidekiq_unique_jobs/redis/list.rb +32 -0
  83. data/lib/sidekiq_unique_jobs/redis/set.rb +32 -0
  84. data/lib/sidekiq_unique_jobs/redis/sorted_set.rb +86 -0
  85. data/lib/sidekiq_unique_jobs/redis/string.rb +51 -0
  86. data/lib/sidekiq_unique_jobs/redis.rb +11 -0
  87. data/lib/sidekiq_unique_jobs/reflectable.rb +26 -0
  88. data/lib/sidekiq_unique_jobs/reflections.rb +79 -0
  89. data/lib/sidekiq_unique_jobs/rspec/matchers/have_valid_sidekiq_options.rb +51 -0
  90. data/lib/sidekiq_unique_jobs/rspec/matchers.rb +26 -0
  91. data/lib/sidekiq_unique_jobs/script/caller.rb +127 -0
  92. data/lib/sidekiq_unique_jobs/script.rb +15 -0
  93. data/lib/sidekiq_unique_jobs/server.rb +61 -0
  94. data/lib/sidekiq_unique_jobs/sidekiq_unique_ext.rb +114 -65
  95. data/lib/sidekiq_unique_jobs/sidekiq_unique_jobs.rb +252 -36
  96. data/lib/sidekiq_unique_jobs/sidekiq_worker_methods.rb +47 -32
  97. data/lib/sidekiq_unique_jobs/testing.rb +102 -29
  98. data/lib/sidekiq_unique_jobs/timer_task.rb +299 -0
  99. data/lib/sidekiq_unique_jobs/timing.rb +58 -0
  100. data/lib/sidekiq_unique_jobs/unlockable.rb +20 -4
  101. data/lib/sidekiq_unique_jobs/update_version.rb +25 -0
  102. data/lib/sidekiq_unique_jobs/upgrade_locks.rb +155 -0
  103. data/lib/sidekiq_unique_jobs/version.rb +3 -1
  104. data/lib/sidekiq_unique_jobs/version_check.rb +23 -4
  105. data/lib/sidekiq_unique_jobs/web/helpers.rb +138 -13
  106. data/lib/sidekiq_unique_jobs/web/views/_paging.erb +4 -4
  107. data/lib/sidekiq_unique_jobs/web/views/changelogs.erb +54 -0
  108. data/lib/sidekiq_unique_jobs/web/views/lock.erb +110 -0
  109. data/lib/sidekiq_unique_jobs/web/views/locks.erb +54 -0
  110. data/lib/sidekiq_unique_jobs/web.rb +82 -32
  111. data/lib/sidekiq_unique_jobs.rb +54 -7
  112. data/lib/tasks/changelog.rake +16 -16
  113. metadata +134 -177
  114. data/lib/sidekiq_unique_jobs/client/middleware.rb +0 -56
  115. data/lib/sidekiq_unique_jobs/scripts.rb +0 -118
  116. data/lib/sidekiq_unique_jobs/server/middleware.rb +0 -46
  117. data/lib/sidekiq_unique_jobs/timeout/calculator.rb +0 -63
  118. data/lib/sidekiq_unique_jobs/timeout.rb +0 -8
  119. data/lib/sidekiq_unique_jobs/unique_args.rb +0 -150
  120. data/lib/sidekiq_unique_jobs/util.rb +0 -103
  121. data/lib/sidekiq_unique_jobs/web/views/unique_digest.erb +0 -28
  122. data/lib/sidekiq_unique_jobs/web/views/unique_digests.erb +0 -46
  123. data/redis/acquire_lock.lua +0 -21
  124. data/redis/convert_legacy_lock.lua +0 -13
  125. data/redis/delete.lua +0 -14
  126. data/redis/delete_by_digest.lua +0 -23
  127. data/redis/delete_job_by_digest.lua +0 -60
  128. data/redis/lock.lua +0 -62
  129. data/redis/release_stale_locks.lua +0 -90
  130. data/redis/unlock.lua +0 -35
metadata CHANGED
@@ -1,227 +1,109 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidekiq-unique-jobs
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.0.25
4
+ version: 7.1.33
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mikael Henriksson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-10-28 00:00:00.000000000 Z
11
+ date: 2024-02-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: concurrent-ruby
14
+ name: brpoplpush-redis_script
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.0'
20
- - - ">="
19
+ version: 0.1.1
20
+ - - "<="
21
21
  - !ruby/object:Gem::Version
22
- version: 1.0.5
22
+ version: 2.0.0
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
- - - "~>"
27
+ - - ">"
28
28
  - !ruby/object:Gem::Version
29
- version: '1.0'
30
- - - ">="
29
+ version: 0.1.1
30
+ - - "<="
31
31
  - !ruby/object:Gem::Version
32
- version: 1.0.5
32
+ version: 2.0.0
33
33
  - !ruby/object:Gem::Dependency
34
- name: sidekiq
34
+ name: concurrent-ruby
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
- - - ">="
37
+ - - "~>"
38
38
  - !ruby/object:Gem::Version
39
- version: '4.0'
40
- - - "<"
39
+ version: '1.0'
40
+ - - ">="
41
41
  - !ruby/object:Gem::Version
42
- version: '7.0'
42
+ version: 1.0.5
43
43
  type: :runtime
44
44
  prerelease: false
45
45
  version_requirements: !ruby/object:Gem::Requirement
46
46
  requirements:
47
- - - ">="
47
+ - - "~>"
48
48
  - !ruby/object:Gem::Version
49
- version: '4.0'
50
- - - "<"
49
+ version: '1.0'
50
+ - - ">="
51
51
  - !ruby/object:Gem::Version
52
- version: '7.0'
52
+ version: 1.0.5
53
53
  - !ruby/object:Gem::Dependency
54
- name: thor
54
+ name: redis
55
55
  requirement: !ruby/object:Gem::Requirement
56
56
  requirements:
57
- - - ">="
58
- - !ruby/object:Gem::Version
59
- version: '0.20'
60
57
  - - "<"
61
58
  - !ruby/object:Gem::Version
62
- version: '2.0'
59
+ version: '5.0'
63
60
  type: :runtime
64
61
  prerelease: false
65
62
  version_requirements: !ruby/object:Gem::Requirement
66
63
  requirements:
67
- - - ">="
68
- - !ruby/object:Gem::Version
69
- version: '0.20'
70
64
  - - "<"
71
65
  - !ruby/object:Gem::Version
72
- version: '2.0'
66
+ version: '5.0'
73
67
  - !ruby/object:Gem::Dependency
74
- name: bundler
75
- requirement: !ruby/object:Gem::Requirement
76
- requirements:
77
- - - "~>"
78
- - !ruby/object:Gem::Version
79
- version: '2.0'
80
- type: :development
81
- prerelease: false
82
- version_requirements: !ruby/object:Gem::Requirement
83
- requirements:
84
- - - "~>"
85
- - !ruby/object:Gem::Version
86
- version: '2.0'
87
- - !ruby/object:Gem::Dependency
88
- name: rack-test
68
+ name: sidekiq
89
69
  requirement: !ruby/object:Gem::Requirement
90
70
  requirements:
91
71
  - - ">="
92
72
  - !ruby/object:Gem::Version
93
- version: '1.0'
73
+ version: '5.0'
94
74
  - - "<"
95
75
  - !ruby/object:Gem::Version
96
- version: '2.0'
97
- type: :development
76
+ version: '7.0'
77
+ type: :runtime
98
78
  prerelease: false
99
79
  version_requirements: !ruby/object:Gem::Requirement
100
80
  requirements:
101
81
  - - ">="
102
82
  - !ruby/object:Gem::Version
103
- version: '1.0'
83
+ version: '5.0'
104
84
  - - "<"
105
85
  - !ruby/object:Gem::Version
106
- version: '2.0'
107
- - !ruby/object:Gem::Dependency
108
- name: rake
109
- requirement: !ruby/object:Gem::Requirement
110
- requirements:
111
- - - "~>"
112
- - !ruby/object:Gem::Version
113
- version: '12.3'
114
- type: :development
115
- prerelease: false
116
- version_requirements: !ruby/object:Gem::Requirement
117
- requirements:
118
- - - "~>"
119
- - !ruby/object:Gem::Version
120
- version: '12.3'
121
- - !ruby/object:Gem::Dependency
122
- name: rspec
123
- requirement: !ruby/object:Gem::Requirement
124
- requirements:
125
- - - "~>"
126
- - !ruby/object:Gem::Version
127
- version: '3.7'
128
- type: :development
129
- prerelease: false
130
- version_requirements: !ruby/object:Gem::Requirement
131
- requirements:
132
- - - "~>"
133
- - !ruby/object:Gem::Version
134
- version: '3.7'
86
+ version: '7.0'
135
87
  - !ruby/object:Gem::Dependency
136
- name: sinatra
88
+ name: thor
137
89
  requirement: !ruby/object:Gem::Requirement
138
90
  requirements:
139
91
  - - ">="
140
92
  - !ruby/object:Gem::Version
141
- version: '2.0'
93
+ version: '0.20'
142
94
  - - "<"
143
95
  - !ruby/object:Gem::Version
144
96
  version: '3.0'
145
- type: :development
97
+ type: :runtime
146
98
  prerelease: false
147
99
  version_requirements: !ruby/object:Gem::Requirement
148
100
  requirements:
149
101
  - - ">="
150
102
  - !ruby/object:Gem::Version
151
- version: '2.0'
103
+ version: '0.20'
152
104
  - - "<"
153
105
  - !ruby/object:Gem::Version
154
106
  version: '3.0'
155
- - !ruby/object:Gem::Dependency
156
- name: timecop
157
- requirement: !ruby/object:Gem::Requirement
158
- requirements:
159
- - - "~>"
160
- - !ruby/object:Gem::Version
161
- version: '0.9'
162
- type: :development
163
- prerelease: false
164
- version_requirements: !ruby/object:Gem::Requirement
165
- requirements:
166
- - - "~>"
167
- - !ruby/object:Gem::Version
168
- version: '0.9'
169
- - !ruby/object:Gem::Dependency
170
- name: github-markup
171
- requirement: !ruby/object:Gem::Requirement
172
- requirements:
173
- - - "~>"
174
- - !ruby/object:Gem::Version
175
- version: '3.0'
176
- type: :development
177
- prerelease: false
178
- version_requirements: !ruby/object:Gem::Requirement
179
- requirements:
180
- - - "~>"
181
- - !ruby/object:Gem::Version
182
- version: '3.0'
183
- - !ruby/object:Gem::Dependency
184
- name: github_changelog_generator
185
- requirement: !ruby/object:Gem::Requirement
186
- requirements:
187
- - - "~>"
188
- - !ruby/object:Gem::Version
189
- version: '1.14'
190
- type: :development
191
- prerelease: false
192
- version_requirements: !ruby/object:Gem::Requirement
193
- requirements:
194
- - - "~>"
195
- - !ruby/object:Gem::Version
196
- version: '1.14'
197
- - !ruby/object:Gem::Dependency
198
- name: yard
199
- requirement: !ruby/object:Gem::Requirement
200
- requirements:
201
- - - "~>"
202
- - !ruby/object:Gem::Version
203
- version: 0.9.18
204
- type: :development
205
- prerelease: false
206
- version_requirements: !ruby/object:Gem::Requirement
207
- requirements:
208
- - - "~>"
209
- - !ruby/object:Gem::Version
210
- version: 0.9.18
211
- - !ruby/object:Gem::Dependency
212
- name: gem-release
213
- requirement: !ruby/object:Gem::Requirement
214
- requirements:
215
- - - "~>"
216
- - !ruby/object:Gem::Version
217
- version: '2.0'
218
- type: :development
219
- prerelease: false
220
- version_requirements: !ruby/object:Gem::Requirement
221
- requirements:
222
- - - "~>"
223
- - !ruby/object:Gem::Version
224
- version: '2.0'
225
107
  description: |
226
108
  Prevents simultaneous Sidekiq jobs with the same unique arguments to run.
227
109
  Highly configurable to suite your specific needs.
@@ -238,24 +120,65 @@ files:
238
120
  - bin/uniquejobs
239
121
  - lib/sidekiq-unique-jobs.rb
240
122
  - lib/sidekiq_unique_jobs.rb
123
+ - lib/sidekiq_unique_jobs/batch_delete.rb
124
+ - lib/sidekiq_unique_jobs/changelog.rb
241
125
  - lib/sidekiq_unique_jobs/cli.rb
242
- - lib/sidekiq_unique_jobs/client/middleware.rb
126
+ - lib/sidekiq_unique_jobs/config.rb
243
127
  - lib/sidekiq_unique_jobs/connection.rb
244
128
  - lib/sidekiq_unique_jobs/constants.rb
245
129
  - lib/sidekiq_unique_jobs/core_ext.rb
130
+ - lib/sidekiq_unique_jobs/deprecation.rb
246
131
  - lib/sidekiq_unique_jobs/digests.rb
247
132
  - lib/sidekiq_unique_jobs/exceptions.rb
133
+ - lib/sidekiq_unique_jobs/expiring_digests.rb
248
134
  - lib/sidekiq_unique_jobs/job.rb
135
+ - lib/sidekiq_unique_jobs/json.rb
136
+ - lib/sidekiq_unique_jobs/key.rb
137
+ - lib/sidekiq_unique_jobs/lock.rb
249
138
  - lib/sidekiq_unique_jobs/lock/base_lock.rb
139
+ - lib/sidekiq_unique_jobs/lock/client_validator.rb
140
+ - lib/sidekiq_unique_jobs/lock/server_validator.rb
250
141
  - lib/sidekiq_unique_jobs/lock/until_and_while_executing.rb
251
142
  - lib/sidekiq_unique_jobs/lock/until_executed.rb
252
143
  - lib/sidekiq_unique_jobs/lock/until_executing.rb
253
144
  - lib/sidekiq_unique_jobs/lock/until_expired.rb
145
+ - lib/sidekiq_unique_jobs/lock/validator.rb
254
146
  - lib/sidekiq_unique_jobs/lock/while_executing.rb
255
147
  - lib/sidekiq_unique_jobs/lock/while_executing_reject.rb
148
+ - lib/sidekiq_unique_jobs/lock_args.rb
149
+ - lib/sidekiq_unique_jobs/lock_config.rb
150
+ - lib/sidekiq_unique_jobs/lock_digest.rb
151
+ - lib/sidekiq_unique_jobs/lock_info.rb
152
+ - lib/sidekiq_unique_jobs/lock_timeout.rb
153
+ - lib/sidekiq_unique_jobs/lock_ttl.rb
154
+ - lib/sidekiq_unique_jobs/lock_type.rb
256
155
  - lib/sidekiq_unique_jobs/locksmith.rb
257
156
  - lib/sidekiq_unique_jobs/logging.rb
157
+ - lib/sidekiq_unique_jobs/logging/middleware_context.rb
158
+ - lib/sidekiq_unique_jobs/lua/delete.lua
159
+ - lib/sidekiq_unique_jobs/lua/delete_by_digest.lua
160
+ - lib/sidekiq_unique_jobs/lua/delete_job_by_digest.lua
161
+ - lib/sidekiq_unique_jobs/lua/find_digest_in_queues.lua
162
+ - lib/sidekiq_unique_jobs/lua/lock.lua
163
+ - lib/sidekiq_unique_jobs/lua/lock_until_expired.lua
164
+ - lib/sidekiq_unique_jobs/lua/locked.lua
165
+ - lib/sidekiq_unique_jobs/lua/queue.lua
166
+ - lib/sidekiq_unique_jobs/lua/reap_orphans.lua
167
+ - lib/sidekiq_unique_jobs/lua/shared/_common.lua
168
+ - lib/sidekiq_unique_jobs/lua/shared/_current_time.lua
169
+ - lib/sidekiq_unique_jobs/lua/shared/_delete_from_queue.lua
170
+ - lib/sidekiq_unique_jobs/lua/shared/_delete_from_sorted_set.lua
171
+ - lib/sidekiq_unique_jobs/lua/shared/_find_digest_in_process_set.lua
172
+ - lib/sidekiq_unique_jobs/lua/shared/_find_digest_in_queues.lua
173
+ - lib/sidekiq_unique_jobs/lua/shared/_find_digest_in_sorted_set.lua
174
+ - lib/sidekiq_unique_jobs/lua/shared/_hgetall.lua
175
+ - lib/sidekiq_unique_jobs/lua/shared/_upgrades.lua
176
+ - lib/sidekiq_unique_jobs/lua/unlock.lua
177
+ - lib/sidekiq_unique_jobs/lua/update_version.lua
178
+ - lib/sidekiq_unique_jobs/lua/upgrade.lua
258
179
  - lib/sidekiq_unique_jobs/middleware.rb
180
+ - lib/sidekiq_unique_jobs/middleware/client.rb
181
+ - lib/sidekiq_unique_jobs/middleware/server.rb
259
182
  - lib/sidekiq_unique_jobs/normalizer.rb
260
183
  - lib/sidekiq_unique_jobs/on_conflict.rb
261
184
  - lib/sidekiq_unique_jobs/on_conflict/log.rb
@@ -266,43 +189,77 @@ files:
266
189
  - lib/sidekiq_unique_jobs/on_conflict/reschedule.rb
267
190
  - lib/sidekiq_unique_jobs/on_conflict/strategy.rb
268
191
  - lib/sidekiq_unique_jobs/options_with_fallback.rb
269
- - lib/sidekiq_unique_jobs/scripts.rb
270
- - lib/sidekiq_unique_jobs/server/middleware.rb
192
+ - lib/sidekiq_unique_jobs/orphans/lua_reaper.rb
193
+ - lib/sidekiq_unique_jobs/orphans/manager.rb
194
+ - lib/sidekiq_unique_jobs/orphans/null_reaper.rb
195
+ - lib/sidekiq_unique_jobs/orphans/observer.rb
196
+ - lib/sidekiq_unique_jobs/orphans/reaper.rb
197
+ - lib/sidekiq_unique_jobs/orphans/reaper_resurrector.rb
198
+ - lib/sidekiq_unique_jobs/orphans/ruby_reaper.rb
199
+ - lib/sidekiq_unique_jobs/redis.rb
200
+ - lib/sidekiq_unique_jobs/redis/entity.rb
201
+ - lib/sidekiq_unique_jobs/redis/hash.rb
202
+ - lib/sidekiq_unique_jobs/redis/list.rb
203
+ - lib/sidekiq_unique_jobs/redis/set.rb
204
+ - lib/sidekiq_unique_jobs/redis/sorted_set.rb
205
+ - lib/sidekiq_unique_jobs/redis/string.rb
206
+ - lib/sidekiq_unique_jobs/reflectable.rb
207
+ - lib/sidekiq_unique_jobs/reflections.rb
208
+ - lib/sidekiq_unique_jobs/rspec/matchers.rb
209
+ - lib/sidekiq_unique_jobs/rspec/matchers/have_valid_sidekiq_options.rb
210
+ - lib/sidekiq_unique_jobs/script.rb
211
+ - lib/sidekiq_unique_jobs/script/caller.rb
212
+ - lib/sidekiq_unique_jobs/server.rb
271
213
  - lib/sidekiq_unique_jobs/sidekiq_unique_ext.rb
272
214
  - lib/sidekiq_unique_jobs/sidekiq_unique_jobs.rb
273
215
  - lib/sidekiq_unique_jobs/sidekiq_worker_methods.rb
274
216
  - lib/sidekiq_unique_jobs/testing.rb
275
- - lib/sidekiq_unique_jobs/timeout.rb
276
- - lib/sidekiq_unique_jobs/timeout/calculator.rb
277
- - lib/sidekiq_unique_jobs/unique_args.rb
217
+ - lib/sidekiq_unique_jobs/timer_task.rb
218
+ - lib/sidekiq_unique_jobs/timing.rb
278
219
  - lib/sidekiq_unique_jobs/unlockable.rb
279
- - lib/sidekiq_unique_jobs/util.rb
220
+ - lib/sidekiq_unique_jobs/update_version.rb
221
+ - lib/sidekiq_unique_jobs/upgrade_locks.rb
280
222
  - lib/sidekiq_unique_jobs/version.rb
281
223
  - lib/sidekiq_unique_jobs/version_check.rb
282
224
  - lib/sidekiq_unique_jobs/web.rb
283
225
  - lib/sidekiq_unique_jobs/web/helpers.rb
284
226
  - lib/sidekiq_unique_jobs/web/views/_paging.erb
285
- - lib/sidekiq_unique_jobs/web/views/unique_digest.erb
286
- - lib/sidekiq_unique_jobs/web/views/unique_digests.erb
227
+ - lib/sidekiq_unique_jobs/web/views/changelogs.erb
228
+ - lib/sidekiq_unique_jobs/web/views/lock.erb
229
+ - lib/sidekiq_unique_jobs/web/views/locks.erb
287
230
  - lib/tasks/changelog.rake
288
- - redis/acquire_lock.lua
289
- - redis/convert_legacy_lock.lua
290
- - redis/delete.lua
291
- - redis/delete_by_digest.lua
292
- - redis/delete_job_by_digest.lua
293
- - redis/lock.lua
294
- - redis/release_stale_locks.lua
295
- - redis/unlock.lua
296
- homepage: https://mhenrixon.github.io/sidekiq-unique-jobs
231
+ homepage: https://github.com/mhenrixon/sidekiq-unique-jobs
297
232
  licenses:
298
233
  - MIT
299
234
  metadata:
300
- homepage_uri: https://mhenrixon.github.io/sidekiq-unique-jobs
301
- bug_tracker_uri: https://github.com/mhenrixon/sidekiq-unique-jobs/issues
302
- documentation_uri: https://mhenrixon.github.io/sidekiq-unique-jobs
303
- source_code_uri: https://github.com/mhenrixon/sidekiq-unique-jobs
304
- changelog_uri: https://github.com/mhenrixon/sidekiq-unique-jobs/CHANGELOG.md
305
- post_install_message:
235
+ rubygems_mfa_required: 'true'
236
+ post_install_message: |
237
+ IMPORTANT!
238
+
239
+ Automatic configuration of the sidekiq middleware is no longer done.
240
+ Please see: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/master/README.md#add-the-middleware
241
+
242
+ This version deprecated the following sidekiq_options
243
+
244
+ - sidekiq_options lock_args: :method_name
245
+
246
+ It is now configured with:
247
+
248
+ - sidekiq_options lock_args_method: :method_name
249
+
250
+ This is also true for `Sidekiq.default_worker_options`
251
+
252
+ We also deprecated the global configuration options:
253
+ - default_lock_ttl
254
+ - default_lock_ttl=
255
+ - default_lock_timeout
256
+ - default_lock_timeout=
257
+
258
+ The new methods to use are:
259
+ - lock_ttl
260
+ - lock_ttl=
261
+ - lock_timeout
262
+ - lock_timeout=
306
263
  rdoc_options: []
307
264
  require_paths:
308
265
  - lib
@@ -310,14 +267,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
310
267
  requirements:
311
268
  - - ">="
312
269
  - !ruby/object:Gem::Version
313
- version: '0'
270
+ version: '2.5'
314
271
  required_rubygems_version: !ruby/object:Gem::Requirement
315
272
  requirements:
316
273
  - - ">="
317
274
  - !ruby/object:Gem::Version
318
275
  version: '0'
319
276
  requirements: []
320
- rubygems_version: 3.1.2
277
+ rubygems_version: 3.5.6
321
278
  signing_key:
322
279
  specification_version: 4
323
280
  summary: Sidekiq middleware that prevents duplicates jobs
@@ -1,56 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "sidekiq_unique_jobs/server/middleware"
4
-
5
- module SidekiqUniqueJobs
6
- module Client
7
- # The unique sidekiq middleware for the client push
8
- #
9
- # @author Mikael Henriksson <mikael@zoolutions.se>
10
- class Middleware
11
- include SidekiqUniqueJobs::Logging
12
- include OptionsWithFallback
13
-
14
- # Calls this client middleware
15
- # Used from Sidekiq.process_single
16
- # @param [String] worker_class name of the sidekiq worker class
17
- # @param [Hash] item a sidekiq job hash
18
- # @param [String] queue name of the queue
19
- # @param [Sidekiq::RedisConnection, ConnectionPool] redis_pool the redis connection
20
- # @yield when uniqueness is disable or lock successful
21
- def call(worker_class, item, queue, redis_pool = nil)
22
- @worker_class = worker_class
23
- @item = item
24
- @queue = queue
25
- @redis_pool = redis_pool
26
-
27
- yield if success?
28
- end
29
-
30
- private
31
-
32
- # The sidekiq job hash
33
- # @return [Hash] the Sidekiq job hash
34
- attr_reader :item
35
-
36
- def success?
37
- unique_disabled? || locked?
38
- end
39
-
40
- def locked?
41
- SidekiqUniqueJobs::Job.add_uniqueness(item)
42
- SidekiqUniqueJobs.with_context(logging_context(self.class, item)) do
43
- locked = lock.lock
44
- warn_about_duplicate unless locked
45
- locked
46
- end
47
- end
48
-
49
- def warn_about_duplicate
50
- return unless log_duplicate_payload?
51
-
52
- log_warn "payload is not unique #{item}"
53
- end
54
- end
55
- end
56
- end
@@ -1,118 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "pathname"
4
- require "digest/sha1"
5
- require "concurrent/map"
6
-
7
- module SidekiqUniqueJobs
8
- # Interface to dealing with .lua files
9
- #
10
- # @author Mikael Henriksson <mikael@zoolutions.se>
11
- module Scripts
12
- LUA_PATHNAME ||= Pathname.new(__FILE__).dirname.join("../../redis").freeze
13
- SCRIPT_SHAS ||= Concurrent::Map.new
14
-
15
- include SidekiqUniqueJobs::Connection
16
-
17
- module_function
18
-
19
- #
20
- # Call a lua script with the provided file_name
21
- #
22
- # @note this method is recursive if we need to load a lua script
23
- # that wasn't previously loaded.
24
- #
25
- # @param [Symbol] file_name the name of the lua script
26
- # @param [Sidekiq::RedisConnection, ConnectionPool] redis_pool the redis connection
27
- # @param [Hash] options arguments to pass to the script file
28
- # @option options [Array] :keys the array of keys to pass to the script
29
- # @option options [Array] :argv the array of arguments to pass to the script
30
- #
31
- # @return value from script
32
- #
33
- def call(file_name, redis_pool, options = {})
34
- execute_script(file_name, redis_pool, options)
35
- rescue Redis::CommandError => ex
36
- handle_error(ex, file_name) do
37
- call(file_name, redis_pool, options)
38
- end
39
- end
40
-
41
- #
42
- # Execute the script file
43
- #
44
- # @param [Symbol] file_name the name of the lua script
45
- # @param [Sidekiq::RedisConnection, ConnectionPool] redis_pool the redis connection
46
- # @param [Hash] options arguments to pass to the script file
47
- # @option options [Array] :keys the array of keys to pass to the script
48
- # @option options [Array] :argv the array of arguments to pass to the script
49
- #
50
- # @return value from script (evalsha)
51
- #
52
- def execute_script(file_name, redis_pool, options = {})
53
- redis(redis_pool) do |conn|
54
- sha = script_sha(conn, file_name)
55
- conn.evalsha(sha, options)
56
- end
57
- end
58
-
59
- #
60
- # Return sha of already loaded lua script or load it and return the sha
61
- #
62
- # @param [Sidekiq::RedisConnection] conn the redis connection
63
- # @param [Symbol] file_name the name of the lua script
64
- # @return [String] sha of the script file
65
- #
66
- # @return [String] the sha of the script
67
- #
68
- def script_sha(conn, file_name)
69
- if (sha = SCRIPT_SHAS.get(file_name))
70
- return sha
71
- end
72
-
73
- sha = conn.script(:load, script_source(file_name))
74
- SCRIPT_SHAS.put(file_name, sha)
75
- sha
76
- end
77
-
78
- #
79
- # Handle errors to allow retrying errors that need retrying
80
- #
81
- # @param [Redis::CommandError] ex exception to handle
82
- # @param [Symbol] file_name the name of the lua script
83
- #
84
- # @return [void]
85
- #
86
- # @yieldreturn [void] yields back to the caller when NOSCRIPT is raised
87
- def handle_error(ex, file_name)
88
- if ex.message == "NOSCRIPT No matching script. Please use EVAL."
89
- SCRIPT_SHAS.delete(file_name)
90
- return yield if block_given?
91
- end
92
-
93
- raise ScriptError, file_name: file_name, source_exception: ex
94
- end
95
-
96
- #
97
- # Reads the lua file from disk
98
- #
99
- # @param [Symbol] file_name the name of the lua script
100
- #
101
- # @return [String] the content of the lua file
102
- #
103
- def script_source(file_name)
104
- script_path(file_name).read
105
- end
106
-
107
- #
108
- # Construct a Pathname to a lua script
109
- #
110
- # @param [Symbol] file_name the name of the lua script
111
- #
112
- # @return [Pathname] the full path to the gems lua script
113
- #
114
- def script_path(file_name)
115
- LUA_PATHNAME.join("#{file_name}.lua")
116
- end
117
- end
118
- end
@@ -1,46 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module SidekiqUniqueJobs
4
- module Server
5
- # The unique sidekiq middleware for the server processor
6
- #
7
- # @author Mikael Henriksson <mikael@zoolutions.se>
8
- class Middleware
9
- include Logging
10
- include OptionsWithFallback
11
-
12
- #
13
- #
14
- # Runs the server middleware (used from Sidekiq::Processor#process)
15
- #
16
- # @param [Sidekiq::Worker] worker_class
17
- # @param [Hash] item a sidekiq job hash
18
- # @param [String] queue name of the queue
19
- #
20
- # @see https://github.com/mperham/sidekiq/wiki/Job-Format
21
- # @see https://github.com/mperham/sidekiq/wiki/Middleware
22
- #
23
- # @yield when uniqueness is disabled
24
- # @yield when the lock is acquired
25
- def call(worker_class, item, queue)
26
- @worker_class = worker_class
27
- @item = item
28
- @queue = queue
29
- return yield if unique_disabled?
30
-
31
- SidekiqUniqueJobs::Job.add_uniqueness(item)
32
- SidekiqUniqueJobs.with_context(logging_context(self.class, item)) do
33
- lock.execute do
34
- yield
35
- end
36
- end
37
- end
38
-
39
- private
40
-
41
- # The sidekiq job hash
42
- # @return [Hash] the Sidekiq job hash
43
- attr_reader :item
44
- end
45
- end
46
- end