sidekiq-unique-jobs 5.0.2 → 5.0.11

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 (207) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +8 -0
  3. data/.rubocop.yml +20 -13
  4. data/.simplecov +1 -1
  5. data/.travis.yml +30 -20
  6. data/Appraisals +10 -2
  7. data/CHANGELOG.md +33 -0
  8. data/CODE_OF_CONDUCT.md +74 -0
  9. data/Gemfile +13 -12
  10. data/LICENSE.txt +21 -0
  11. data/README.md +48 -4
  12. data/Rakefile +0 -1
  13. data/bin/bench +1 -1
  14. data/lib/sidekiq/simulator.rb +4 -10
  15. data/lib/sidekiq-unique-jobs.rb +16 -6
  16. data/lib/sidekiq_unique_jobs/cli.rb +14 -12
  17. data/lib/sidekiq_unique_jobs/client/middleware.rb +2 -0
  18. data/lib/sidekiq_unique_jobs/config.rb +2 -0
  19. data/lib/sidekiq_unique_jobs/constants.rb +20 -17
  20. data/lib/sidekiq_unique_jobs/core_ext.rb +18 -0
  21. data/lib/sidekiq_unique_jobs/lock/until_and_while_executing.rb +2 -0
  22. data/lib/sidekiq_unique_jobs/lock/until_executed.rb +4 -5
  23. data/lib/sidekiq_unique_jobs/lock/until_executing.rb +2 -0
  24. data/lib/sidekiq_unique_jobs/lock/until_timeout.rb +2 -0
  25. data/lib/sidekiq_unique_jobs/lock/while_executing.rb +10 -9
  26. data/lib/sidekiq_unique_jobs/lock.rb +2 -0
  27. data/lib/sidekiq_unique_jobs/middleware.rb +2 -0
  28. data/lib/sidekiq_unique_jobs/normalizer.rb +3 -1
  29. data/lib/sidekiq_unique_jobs/options_with_fallback.rb +22 -3
  30. data/lib/sidekiq_unique_jobs/run_lock_failed.rb +2 -0
  31. data/lib/sidekiq_unique_jobs/script_mock.rb +16 -15
  32. data/lib/sidekiq_unique_jobs/scripts/acquire_lock.rb +2 -0
  33. data/lib/sidekiq_unique_jobs/scripts/release_lock.rb +2 -0
  34. data/lib/sidekiq_unique_jobs/scripts.rb +17 -12
  35. data/lib/sidekiq_unique_jobs/server/middleware.rb +2 -0
  36. data/lib/sidekiq_unique_jobs/sidekiq_unique_ext.rb +4 -14
  37. data/lib/sidekiq_unique_jobs/testing/sidekiq_overrides.rb +2 -0
  38. data/lib/sidekiq_unique_jobs/testing.rb +4 -2
  39. data/lib/sidekiq_unique_jobs/timeout_calculator.rb +2 -0
  40. data/lib/sidekiq_unique_jobs/unique_args.rb +27 -14
  41. data/lib/sidekiq_unique_jobs/unlockable.rb +6 -6
  42. data/lib/sidekiq_unique_jobs/util.rb +34 -14
  43. data/lib/sidekiq_unique_jobs/version.rb +3 -1
  44. data/redis/acquire_lock.lua +1 -1
  45. data/sidekiq-unique-jobs.gemspec +27 -23
  46. metadata +44 -212
  47. data/LICENSE +0 -13
  48. data/circle.yml +0 -41
  49. data/gemfiles/sidekiq_4.0.gemfile +0 -22
  50. data/gemfiles/sidekiq_4.1.gemfile +0 -22
  51. data/gemfiles/sidekiq_4.2.gemfile +0 -22
  52. data/gemfiles/sidekiq_5.0.gemfile +0 -22
  53. data/gemfiles/sidekiq_develop.gemfile +0 -22
  54. data/rails_example/.env +0 -12
  55. data/rails_example/.env.test +0 -12
  56. data/rails_example/.gitignore +0 -13
  57. data/rails_example/.rspec +0 -2
  58. data/rails_example/Gemfile +0 -38
  59. data/rails_example/Procfile +0 -2
  60. data/rails_example/README.rdoc +0 -28
  61. data/rails_example/Rakefile +0 -6
  62. data/rails_example/app/assets/images/.keep +0 -0
  63. data/rails_example/app/assets/javascripts/application.js +0 -16
  64. data/rails_example/app/assets/stylesheets/application.css +0 -15
  65. data/rails_example/app/channels/appearance_channel.rb +0 -17
  66. data/rails_example/app/channels/application_cable/channel.rb +0 -4
  67. data/rails_example/app/channels/application_cable/connection.rb +0 -9
  68. data/rails_example/app/channels/post_channel.rb +0 -5
  69. data/rails_example/app/controllers/application_controller.rb +0 -5
  70. data/rails_example/app/controllers/concerns/.keep +0 -0
  71. data/rails_example/app/controllers/work_controller.rb +0 -39
  72. data/rails_example/app/helpers/application_helper.rb +0 -2
  73. data/rails_example/app/mailers/.keep +0 -0
  74. data/rails_example/app/models/.keep +0 -0
  75. data/rails_example/app/models/application_record.rb +0 -3
  76. data/rails_example/app/models/concerns/.keep +0 -0
  77. data/rails_example/app/models/guest.rb +0 -18
  78. data/rails_example/app/models/post.rb +0 -2
  79. data/rails_example/app/views/layouts/application.html.erb +0 -15
  80. data/rails_example/app/workers/simple_worker.rb +0 -15
  81. data/rails_example/app/workers/slow_until_executing_worker.rb +0 -15
  82. data/rails_example/app/workers/spawn_simple_worker.rb +0 -10
  83. data/rails_example/app/workers/while_executing_worker.rb +0 -12
  84. data/rails_example/app/workers/without_args_worker.rb +0 -16
  85. data/rails_example/app/workers/without_argument_worker.rb +0 -12
  86. data/rails_example/bin/bundle +0 -3
  87. data/rails_example/bin/check_or_setup_db +0 -56
  88. data/rails_example/bin/docker-setup +0 -20
  89. data/rails_example/bin/rails +0 -4
  90. data/rails_example/bin/rake +0 -4
  91. data/rails_example/bin/setup +0 -34
  92. data/rails_example/bin/update +0 -29
  93. data/rails_example/cable.ru +0 -6
  94. data/rails_example/common-services.yml +0 -52
  95. data/rails_example/config/application.rb +0 -27
  96. data/rails_example/config/boot.rb +0 -3
  97. data/rails_example/config/cable.yml +0 -9
  98. data/rails_example/config/database.docker.yml +0 -12
  99. data/rails_example/config/database.yml +0 -19
  100. data/rails_example/config/environment.rb +0 -5
  101. data/rails_example/config/environments/development.rb +0 -54
  102. data/rails_example/config/environments/production.rb +0 -86
  103. data/rails_example/config/environments/test.rb +0 -42
  104. data/rails_example/config/initializers/application_controller_renderer.rb +0 -6
  105. data/rails_example/config/initializers/assets.rb +0 -11
  106. data/rails_example/config/initializers/backtrace_silencers.rb +0 -9
  107. data/rails_example/config/initializers/cookies_serializer.rb +0 -5
  108. data/rails_example/config/initializers/filter_parameter_logging.rb +0 -4
  109. data/rails_example/config/initializers/inflections.rb +0 -16
  110. data/rails_example/config/initializers/mime_types.rb +0 -4
  111. data/rails_example/config/initializers/new_framework_defaults.rb +0 -23
  112. data/rails_example/config/initializers/session_store.rb +0 -3
  113. data/rails_example/config/initializers/sidekiq.rb +0 -13
  114. data/rails_example/config/initializers/wrap_parameters.rb +0 -14
  115. data/rails_example/config/locales/en.yml +0 -23
  116. data/rails_example/config/puma.rb +0 -38
  117. data/rails_example/config/routes.rb +0 -8
  118. data/rails_example/config/secrets.yml +0 -22
  119. data/rails_example/config/sidekiq.yml +0 -6
  120. data/rails_example/config/spring.rb +0 -6
  121. data/rails_example/config.ru +0 -4
  122. data/rails_example/db/migrate/20160724111322_create_posts.rb +0 -12
  123. data/rails_example/db/schema.rb +0 -25
  124. data/rails_example/db/seeds.rb +0 -7
  125. data/rails_example/dev-entrypoint.sh +0 -55
  126. data/rails_example/dev.env +0 -12
  127. data/rails_example/docker/rails.Dockerfile +0 -27
  128. data/rails_example/docker-compose.yml +0 -71
  129. data/rails_example/lib/assets/.keep +0 -0
  130. data/rails_example/lib/tasks/.keep +0 -0
  131. data/rails_example/log/.keep +0 -0
  132. data/rails_example/public/404.html +0 -67
  133. data/rails_example/public/422.html +0 -67
  134. data/rails_example/public/500.html +0 -66
  135. data/rails_example/public/favicon.ico +0 -0
  136. data/rails_example/public/robots.txt +0 -5
  137. data/rails_example/simple.ru +0 -12
  138. data/rails_example/spec/controllers/work_controller_mock_spec.rb +0 -91
  139. data/rails_example/spec/controllers/work_controller_spec.rb +0 -77
  140. data/rails_example/spec/factories/posts.rb +0 -8
  141. data/rails_example/spec/models/post_spec.rb +0 -4
  142. data/rails_example/spec/rails_helper.rb +0 -20
  143. data/rails_example/spec/spec_helper.rb +0 -20
  144. data/rails_example/spec/support/sidekiq_meta.rb +0 -12
  145. data/rails_example/spec/workers/simple_worker_spec.rb +0 -4
  146. data/rails_example/vendor/assets/javascripts/.keep +0 -0
  147. data/rails_example/vendor/assets/stylesheets/.keep +0 -0
  148. data/spec/jobs/another_unique_job.rb +0 -13
  149. data/spec/jobs/custom_queue_job.rb +0 -5
  150. data/spec/jobs/custom_queue_job_with_filter_method.rb +0 -7
  151. data/spec/jobs/custom_queue_job_with_filter_proc.rb +0 -10
  152. data/spec/jobs/expiring_job.rb +0 -4
  153. data/spec/jobs/inline_worker.rb +0 -8
  154. data/spec/jobs/just_a_worker.rb +0 -7
  155. data/spec/jobs/long_running_job.rb +0 -6
  156. data/spec/jobs/main_job.rb +0 -7
  157. data/spec/jobs/my_job.rb +0 -12
  158. data/spec/jobs/my_unique_job.rb +0 -11
  159. data/spec/jobs/my_unique_job_with_filter_method.rb +0 -17
  160. data/spec/jobs/my_unique_job_with_filter_proc.rb +0 -15
  161. data/spec/jobs/notify_worker.rb +0 -10
  162. data/spec/jobs/plain_class.rb +0 -3
  163. data/spec/jobs/simple_worker.rb +0 -11
  164. data/spec/jobs/spawn_simple_worker.rb +0 -8
  165. data/spec/jobs/test_class.rb +0 -3
  166. data/spec/jobs/unique_job_with_conditional_parameter.rb +0 -14
  167. data/spec/jobs/unique_job_with_filter_method.rb +0 -18
  168. data/spec/jobs/unique_job_with_nil_unique_args.rb +0 -16
  169. data/spec/jobs/unique_job_with_no_unique_args_method.rb +0 -12
  170. data/spec/jobs/unique_job_withthout_unique_args_parameter.rb +0 -14
  171. data/spec/jobs/unique_on_all_queues_job.rb +0 -13
  172. data/spec/jobs/until_and_while_executing_job.rb +0 -7
  173. data/spec/jobs/until_executed_job.rb +0 -17
  174. data/spec/jobs/until_executing_job.rb +0 -7
  175. data/spec/jobs/until_global_timeout_job.rb +0 -8
  176. data/spec/jobs/until_timeout_job.rb +0 -8
  177. data/spec/jobs/while_executing_job.rb +0 -12
  178. data/spec/jobs/without_argument_job.rb +0 -9
  179. data/spec/lib/sidekiq_unique_jobs/cli_spec.rb +0 -183
  180. data/spec/lib/sidekiq_unique_jobs/client/middleware_spec.rb +0 -316
  181. data/spec/lib/sidekiq_unique_jobs/config_spec.rb +0 -84
  182. data/spec/lib/sidekiq_unique_jobs/core_ext_spec.rb +0 -25
  183. data/spec/lib/sidekiq_unique_jobs/lock/until_and_while_executing_spec.rb +0 -42
  184. data/spec/lib/sidekiq_unique_jobs/lock/until_executed_spec.rb +0 -37
  185. data/spec/lib/sidekiq_unique_jobs/lock/until_timeout_spec.rb +0 -26
  186. data/spec/lib/sidekiq_unique_jobs/lock/while_executing_spec.rb +0 -86
  187. data/spec/lib/sidekiq_unique_jobs/normalizer_spec.rb +0 -21
  188. data/spec/lib/sidekiq_unique_jobs/options_with_fallback_spec.rb +0 -113
  189. data/spec/lib/sidekiq_unique_jobs/queue_lock_timeout_calculator_spec.rb +0 -47
  190. data/spec/lib/sidekiq_unique_jobs/run_lock_timeout_calculator_spec.rb +0 -36
  191. data/spec/lib/sidekiq_unique_jobs/script_mock_spec.rb +0 -88
  192. data/spec/lib/sidekiq_unique_jobs/scripts/acquire_lock_spec.rb +0 -50
  193. data/spec/lib/sidekiq_unique_jobs/scripts/release_lock_spec.rb +0 -41
  194. data/spec/lib/sidekiq_unique_jobs/scripts_spec.rb +0 -68
  195. data/spec/lib/sidekiq_unique_jobs/server/middleware_spec.rb +0 -78
  196. data/spec/lib/sidekiq_unique_jobs/sidekiq_testing_enabled_spec.rb +0 -164
  197. data/spec/lib/sidekiq_unique_jobs/sidekiq_unique_ext_spec.rb +0 -75
  198. data/spec/lib/sidekiq_unique_jobs/sidekiq_unique_jobs_spec.rb +0 -41
  199. data/spec/lib/sidekiq_unique_jobs/timeout_calculator_spec.rb +0 -70
  200. data/spec/lib/sidekiq_unique_jobs/unique_args_spec.rb +0 -257
  201. data/spec/lib/sidekiq_unique_jobs/unlockable_spec.rb +0 -37
  202. data/spec/lib/sidekiq_unique_jobs/util_spec.rb +0 -81
  203. data/spec/spec_helper.rb +0 -92
  204. data/spec/support/matchers/redis_matchers.rb +0 -29
  205. data/spec/support/ruby_meta.rb +0 -17
  206. data/spec/support/sidekiq_meta.rb +0 -30
  207. data/spec/support/unique_macros.rb +0 -71
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 4ca11c77223ec339ed2dba0bbfa3630c17db88df
4
- data.tar.gz: 8ac3ea5ed96f4303663cd7a43b3b70e93ece13c5
2
+ SHA256:
3
+ metadata.gz: 87c40a03b7114fd7c5b1c56ceaaf8f4d96b19939bd06f0b76e0c3ce088e34ee1
4
+ data.tar.gz: 7b41fc69c8cd77117a56beb1d15a17b523f4bff7a742317735cfcc28cda121de
5
5
  SHA512:
6
- metadata.gz: ab6f325ea2633be2150c15f9441133901ec42fa767a5777328df8c44438fab1e8eddbb674a4f11132028899f7fab6c2a19dc1541dd9e2acea257e58bb96b3aca
7
- data.tar.gz: ece51ecdb1244507c06a5336d78106b92423b13d026d4c1f8a0ebadad778526522ce52efc7199b41530295fd2865f1732e53029ad929c51f70ef62ab944d79c3
6
+ metadata.gz: 78dbf85901350c5b9e9e10889b25de771ef1c9757ac1e9a3565bc7b447501d0505770a3e9befda2242f855319c373777fee01e9c92c37bf1facdbeac87cb052e
7
+ data.tar.gz: ae243b12f6a0b4db056f474584e53017076226a93e87cc9fd45f7525f7e4a0e44da076a5725895405a3f6db6588578664cd0bc3fba746f139bb0ff65aba8f565
data/.gitignore CHANGED
@@ -14,3 +14,11 @@ tmp/
14
14
  rails_example/spec/examples.txt
15
15
 
16
16
  *.sublime-*
17
+
18
+ /sidekiq/
19
+
20
+ /spec/examples.txt
21
+
22
+ /gemfiles/.bundle/
23
+
24
+ /.rspec_status
data/.rubocop.yml CHANGED
@@ -1,13 +1,13 @@
1
1
  AllCops:
2
2
  Include:
3
3
  - '**/Rakefile'
4
- - '**/lib'
5
- - '**/bin'
6
- - '**/spec'
4
+ - 'lib/**/*.rb'
5
+ - 'bin/**/*.rb'
6
+ - 'spec/**/*.rb'
7
7
  Exclude:
8
8
  - 'Gemfile.lock'
9
9
  - 'gemfiles/**/*'
10
- TargetRubyVersion: 2.4
10
+ TargetRubyVersion: 2.5
11
11
 
12
12
  Lint/HandleExceptions:
13
13
  Enabled: true
@@ -35,23 +35,26 @@ Metrics/BlockLength:
35
35
  Metrics/PerceivedComplexity:
36
36
  Max: 8
37
37
 
38
- Style/AccessorMethodName:
38
+ Naming/AccessorMethodName:
39
39
  Enabled: true
40
40
 
41
- Style/ConstantName:
41
+ Naming/ConstantName:
42
42
  Enabled: true
43
43
 
44
+ Naming/FileName:
45
+ Enabled: true
46
+ Exclude:
47
+ - 'lib/sidekiq-unique-jobs.rb'
48
+ - '**/Gemfile'
49
+ - '**/Appraisals'
50
+ - '**/*.gemspec'
51
+
44
52
  Style/FrozenStringLiteralComment:
45
- Enabled: false
53
+ Enabled: true
46
54
 
47
55
  Style/Documentation:
48
56
  Enabled: false
49
57
 
50
- Style/FileName:
51
- Enabled: true
52
- Exclude:
53
- - 'lib/sidekiq-unique-jobs.rb'
54
-
55
58
  Style/GlobalVars:
56
59
  Enabled: true
57
60
 
@@ -77,6 +80,10 @@ Style/TrailingCommaInArguments:
77
80
  Enabled: true
78
81
  EnforcedStyleForMultiline: comma
79
82
 
80
- Style/TrailingCommaInLiteral:
83
+ Style/TrailingCommaInArrayLiteral:
84
+ Enabled: true
85
+ EnforcedStyleForMultiline: comma
86
+
87
+ Style/TrailingCommaInHashLiteral:
81
88
  Enabled: true
82
89
  EnforcedStyleForMultiline: comma
data/.simplecov CHANGED
@@ -2,7 +2,7 @@ require 'simplecov-json'
2
2
  require 'codeclimate-test-reporter'
3
3
 
4
4
  SimpleCov.command_name 'rspec'
5
- SimpleCov.refuse_coverage_drop
5
+ # SimpleCov.refuse_coverage_drop
6
6
  SimpleCov.formatters = [
7
7
  SimpleCov::Formatter::HTMLFormatter,
8
8
  SimpleCov::Formatter::JSONFormatter,
data/.travis.yml CHANGED
@@ -1,38 +1,48 @@
1
- sudo: false
1
+ env:
2
+ matrix:
3
+ - COV=false
4
+ global:
5
+ - CC_TEST_REPORTER_ID=88e524e8f638efe690def7a6e2c72b1a9db5cdfa74548921b734d609a5858ee5
6
+ - GIT_COMMITTED_AT=$(if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then git log -1 --pretty=format:%ct; else git log -1 --skip 1 --pretty=format:%ct; fi)
7
+ dist: trusty
8
+ sudo: required
2
9
  language: ruby
3
10
  cache: bundler
4
- # before_install:
5
- # - rvm get head
6
- # - gem update --system
7
- # - gem install bundler
8
11
  services:
9
12
  - redis-server
13
+
14
+ before_install:
15
+ - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
16
+ - chmod +x ./cc-test-reporter
17
+ before_script:
18
+ - ./cc-test-reporter before-build
10
19
  script:
11
- - if [[ "${STYLE}" = "true" ]]; then bundle exec rubocop; fi;
12
- - bundle exec rspec spec
13
- - if [[ "${STYLE}" = "true" ]]; then CODECLIMATE_REPO_TOKEN=88e524e8f638efe690def7a6e2c72b1a9db5cdfa74548921b734d609a5858ee5 bundle exec codeclimate-test-reporter; fi;
20
+ - if [[ "${COV}" = "true" ]]; then bundle exec rubocop -P; fi;
21
+ - bundle exec rspec
22
+ after_script:
23
+ - if [[ "${COV}" = "true" ]]; then ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT; fi;
14
24
  rvm:
15
- - 2.4.1
25
+ - 2.5.3
26
+ - 2.4.2
16
27
  - 2.3.2
17
- - jruby-9.1.8.0
18
- env: STYLE=false
28
+ - 2.2.7
29
+ - jruby-9.2.0.0
30
+ matrix:
31
+ fast_finish: true
32
+ include:
33
+ - rvm: 2.5.3
34
+ gemfile: gemfiles/sidekiq_develop.gemfile
35
+ env: COV=true
19
36
  gemfile:
20
37
  - gemfiles/sidekiq_develop.gemfile
21
38
  - gemfiles/sidekiq_4.0.gemfile
22
39
  - gemfiles/sidekiq_4.1.gemfile
23
40
  - gemfiles/sidekiq_4.2.gemfile
24
41
  - gemfiles/sidekiq_5.0.gemfile
42
+ - gemfiles/sidekiq_5.1.gemfile
43
+ - gemfiles/sidekiq_5.2.gemfile
25
44
 
26
45
  notifications:
27
46
  email:
28
47
  recipients:
29
48
  - mikael@zoolutions.se
30
- matrix:
31
- fast_finish: true
32
- include:
33
- - rvm: 2.4.1
34
- gemfile: gemfiles/sidekiq_develop.gemfile
35
- env: STYLE=true
36
- addons:
37
- code_climate:
38
- repo_token: 88e524e8f638efe690def7a6e2c72b1a9db5cdfa74548921b734d609a5858ee5
data/Appraisals CHANGED
@@ -1,4 +1,4 @@
1
- # rubocop:disable Style/FileName
1
+ # frozen_string_literal: true
2
2
 
3
3
  appraise 'sidekiq-develop' do
4
4
  gem 'sidekiq', github: 'mperham/sidekiq'
@@ -17,5 +17,13 @@ appraise 'sidekiq-4.2' do
17
17
  end
18
18
 
19
19
  appraise 'sidekiq-5.0' do
20
- gem 'sidekiq', '>= 5.0.0.beta', '< 6'
20
+ gem 'sidekiq', '>= 5.0.0', '< 5.1'
21
+ end
22
+
23
+ appraise 'sidekiq-5.1' do
24
+ gem 'sidekiq', '>= 5.1.0', '< 5.2'
25
+ end
26
+
27
+ appraise 'sidekiq-5.2' do
28
+ gem 'sidekiq', '>= 5.2.0', '< 6'
21
29
  end
data/CHANGELOG.md CHANGED
@@ -1,3 +1,36 @@
1
+ ## v5.0.10
2
+
3
+ - Cleans up test setup and make tests more readable
4
+ - Allow raising all errors
5
+ - Log previously hidden errors
6
+ - Revert the changes of v5.0.5 (8a4b7648b8b0ee5d7dc1f5f5a036f41d52ad9a42)
7
+ - Allow name errors in unique args method to be raised
8
+
9
+ ## v5.0.9
10
+ - [#229](https://github.com/mhenrixon/sidekiq-unique-jobs/issues/#229) Use HSCAN for expiring keys
11
+ - [#232](https://github.com/mhenrixon/sidekiq-unique-jobs/issues/#232) Fix testing helper
12
+
13
+ ## v5.0.8
14
+ - Fixes [#220](https://github.com/mhenrixon/sidekiq-unique-jobs/issues/220)
15
+
16
+ ## v5.0.7
17
+ - Fixes [#218](https://github.com/mhenrixon/sidekiq-unique-jobs/issues/218)
18
+
19
+ ## v5.0.6
20
+ - Allow across worker uniquenes: See https://github.com/mhenrixon/sidekiq-unique-jobs/blob/master/spec/jobs/unique_acrosss_workers_job.rb for information
21
+
22
+ ## v5.0.5
23
+ - Use a class level mutex for `while_executing`
24
+
25
+ ## v5.0.4
26
+ - Fixes a problem with installing the gem
27
+
28
+ ## v5.0.3
29
+ - Removes test files and appraisals and such from the released gem version to speed up gem installs
30
+
31
+ ## v5.0.2
32
+ - Added more helpful debug, warning and error messages for failures to collect unique arghuments
33
+
1
34
  ## v5.0.1
2
35
 
3
36
  - Added a command line util for cleaning out expired keys
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at mikael@zoolutions.se. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile CHANGED
@@ -1,20 +1,21 @@
1
- # rubocop:disable Style/FileName
1
+ # frozen_string_literal: true
2
2
 
3
3
  source 'https://rubygems.org'
4
4
  gemspec
5
5
 
6
- gem 'appraisal', '~> 2.0.0'
6
+ gem 'appraisal', '>= 2.0.0'
7
7
  gem 'rspec-its', require: false
8
8
  gem 'rspec-wait', require: false
9
9
 
10
- platforms :mri_24 do
11
- gem 'benchmark-ips', require: false
12
- gem 'codeclimate-test-reporter', require: false
13
- gem 'fasterer', require: false
14
- gem 'memory_profiler', require: false
15
- gem 'mock_redis', require: false
16
- gem 'pry-byebug', require: false
17
- gem 'rubocop', require: false
18
- gem 'simplecov-json', require: false
19
- gem 'travis', require: false
10
+ platforms :mri_25 do
11
+ gem 'benchmark-ips', require: false
12
+ gem 'codeclimate-test-reporter', '>= 1.0.8', require: false
13
+ gem 'fasterer', require: false
14
+ gem 'memory_profiler', require: false
15
+ gem 'mock_redis', require: false
16
+ gem 'pry-byebug', require: false
17
+ gem 'rubocop', require: false
18
+ gem 'simplecov', '>= 0.13', require: false
19
+ gem 'simplecov-json', require: false
20
+ gem 'travis', require: false
20
21
  end
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Mikael Henriksson
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md CHANGED
@@ -41,6 +41,27 @@ sidekiq_options unique: :while_executing
41
41
 
42
42
  Is to make sure that a job can be scheduled any number of times but only executed a single time per argument provided to the job we call this runtime uniqueness. This is probably most useful for background jobs that are fast to execute. (See mhenrixon/sidekiq-unique-jobs#111 for a great example of when this would be right.) While the job is executing/performing no other jobs can be executed at the same time.
43
43
 
44
+ The way it currently works is that the jobs can be put on the queue but any succeedent job will wait until the first one finishes.
45
+
46
+ 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`.
47
+
48
+ In the console you should see something like:
49
+
50
+ ```
51
+ 0:32:24 worker.1 | 2017-04-23T08:32:24.955Z 84404 TID-ougq4thko WhileExecutingWorker JID-400ec51c9523f41cd4a35058 INFO: start
52
+ 10:32:24 worker.1 | 2017-04-23T08:32:24.956Z 84404 TID-ougq8csew WhileExecutingWorker JID-8d6d9168368eedaed7f75763 INFO: start
53
+ 10:32:24 worker.1 | 2017-04-23T08:32:24.957Z 84404 TID-ougq8crt8 WhileExecutingWorker JID-affcd079094c9b26e8b9ba60 INFO: start
54
+ 10:32:24 worker.1 | 2017-04-23T08:32:24.959Z 84404 TID-ougq8cs8s WhileExecutingWorker JID-9e197460c067b22eb1b5d07f INFO: start
55
+ 10:32:24 worker.1 | 2017-04-23T08:32:24.959Z 84404 TID-ougq4thko WhileExecutingWorker JID-400ec51c9523f41cd4a35058 WhileExecutingWorker INFO: perform(1, 2)
56
+ 10:32:34 worker.1 | 2017-04-23T08:32:34.964Z 84404 TID-ougq4thko WhileExecutingWorker JID-400ec51c9523f41cd4a35058 INFO: done: 10.009 sec
57
+ 10:32:34 worker.1 | 2017-04-23T08:32:34.965Z 84404 TID-ougq8csew WhileExecutingWorker JID-8d6d9168368eedaed7f75763 WhileExecutingWorker INFO: perform(1, 2)
58
+ 10:32:44 worker.1 | 2017-04-23T08:32:44.965Z 84404 TID-ougq8crt8 WhileExecutingWorker JID-affcd079094c9b26e8b9ba60 WhileExecutingWorker INFO: perform(1, 2)
59
+ 10:32:44 worker.1 | 2017-04-23T08:32:44.965Z 84404 TID-ougq8csew WhileExecutingWorker JID-8d6d9168368eedaed7f75763 INFO: done: 20.009 sec
60
+ 10:32:54 worker.1 | 2017-04-23T08:32:54.970Z 84404 TID-ougq8cs8s WhileExecutingWorker JID-9e197460c067b22eb1b5d07f WhileExecutingWorker INFO: perform(1, 2)
61
+ 10:32:54 worker.1 | 2017-04-23T08:32:54.969Z 84404 TID-ougq8crt8 WhileExecutingWorker JID-affcd079094c9b26e8b9ba60 INFO: done: 30.012 sec
62
+ 10:33:04 worker.1 | 2017-04-23T08:33:04.973Z 84404 TID-ougq8cs8s WhileExecutingWorker JID-9e197460c067b22eb1b5d07f INFO: done: 40.014 sec
63
+ ```
64
+
44
65
  ### Until Executing
45
66
 
46
67
  ```ruby
@@ -81,8 +102,10 @@ That means it locks for any job with the same arguments to be persisted into red
81
102
 
82
103
  ### Uniqueness Scope
83
104
 
105
+
84
106
  - Queue specific locks
85
- - Across all queues.
107
+ - Across all queues - [spec/jobs/unique_on_all_queues_job.rb](https://github.com/mhenrixon/sidekiq-unique-jobs/blob/master/spec/jobs/unique_on_all_queues_job.rb)
108
+ - Across all workers - [spec/jobs/unique_across_workers_job.rb](https://github.com/mhenrixon/sidekiq-unique-jobs/blob/master/spec/jobs/unique_across_workers_job.rb)
86
109
  - Timed / Scheduled jobs
87
110
 
88
111
  ## Usage
@@ -135,11 +158,11 @@ The method or the proc can return a modified version of args without the transie
135
158
  ```ruby
136
159
  class UniqueJobWithFilterMethod
137
160
  include Sidekiq::Worker
138
- sidekiq_options unique: :until_and_while_execution,
161
+ sidekiq_options unique: :until_and_while_executing,
139
162
  unique_args: :unique_args
140
163
 
141
- def self.unique_args(name, id, options)
142
- [ name, options[:type] ]
164
+ def self.unique_args(args)
165
+ [ args[0], args[2][:type] ]
143
166
  end
144
167
 
145
168
  ...
@@ -158,6 +181,27 @@ end
158
181
 
159
182
  The previous problems with unique args being string in server and symbol in client is no longer a problem because the `UniqueArgs` class accounts for this and converts everything to json now. If you find an edge case please provide and example so that we can add coverage and fix it.
160
183
 
184
+
185
+ It is also quite possible to ensure different types of unique args based on context. I can't vouch for the below example but see [#203](https://github.com/mhenrixon/sidekiq-unique-jobs/issues/203) for the discussion.
186
+
187
+ ```ruby
188
+ class UniqueJobWithFilterMethod
189
+ include Sidekiq::Worker
190
+ sidekiq_options unique: :until_and_while_executing, unique_args: :unique_args
191
+
192
+ def self.unique_args(args)
193
+ if Sidekiq::ProcessSet.new.size > 1
194
+ # sidekiq runtime; uniqueness for the object (first arg)
195
+ args.first
196
+ else
197
+ # queuing from the app; uniqueness for all params
198
+ args
199
+ end
200
+ end
201
+ end
202
+ ```
203
+
204
+
161
205
  ### After Unlock Callback
162
206
 
163
207
  If you are using :after_yield as your unlock ordering, Unique Job offers a callback to perform some work after the block is yielded.
data/Rakefile CHANGED
@@ -1,4 +1,3 @@
1
- #!/usr/bin/env rake
2
1
  # frozen_string_literal: true
3
2
 
4
3
  require 'rubygems'
data/bin/bench CHANGED
@@ -14,7 +14,7 @@ ITERATIONS ||= 10_000
14
14
  Benchmark.ips do |x|
15
15
  x.config(time: 5, warmup: 2)
16
16
  x.report('new_shit') do |_times|
17
- SidekiqUniqueJobs::Scripts.call(:acquire_lock, nil, keys: [SecureRandom.hex], argv: [SecureRandom.hex])
17
+ SidekiqUniqueJobs::Scripts::AcquireLock.execute(nil, SecureRandom.hex, SecureRandom.hex)
18
18
  end
19
19
  x.compare!
20
20
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'sidekiq/launcher'
2
4
  require 'timeout'
3
5
 
@@ -38,19 +40,11 @@ module Sidekiq
38
40
  end
39
41
 
40
42
  def terminate_launcher
41
- if launcher.respond_to?(:alive?)
42
- launcher.terminate # Better to be fast than graceful for our purposes
43
- else
44
- launcher.stop # New sidekiq works better
45
- end
43
+ launcher.stop
46
44
  end
47
45
 
48
46
  def alive?
49
- if launcher.respond_to?(:alive?)
50
- launcher.alive?
51
- else
52
- launcher.manager.workers.any?
53
- end
47
+ launcher.manager.workers.any?
54
48
  end
55
49
 
56
50
  def stopped?
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'yaml' if RUBY_VERSION.include?('2.0.0')
2
4
  require 'forwardable'
3
5
  require 'sidekiq_unique_jobs/version'
@@ -27,6 +29,7 @@ module SidekiqUniqueJobs
27
29
  default_run_lock_expiration: 60,
28
30
  default_lock: :while_executing,
29
31
  redis_test_mode: :redis, # :mock
32
+ raise_unique_args_errors: false,
30
33
  )
31
34
  end
32
35
 
@@ -49,16 +52,23 @@ module SidekiqUniqueJobs
49
52
  end
50
53
 
51
54
  def namespace
52
- @namespace ||= connection { |c| c.respond_to?(:namespace) ? c.namespace : nil }
55
+ @namespace ||= connection { |conn| conn.respond_to?(:namespace) ? conn.namespace : nil }
53
56
  end
54
57
 
55
58
  # Attempt to constantize a string worker_class argument, always
56
- # failing back to the original argument.
59
+ # failing back to the original argument when the constant can't be found
60
+ #
61
+ # raises an error for other errors
57
62
  def worker_class_constantize(worker_class)
58
63
  return worker_class unless worker_class.is_a?(String)
59
- worker_class.constantize
60
- rescue NameError
61
- worker_class
64
+ Object.const_get(worker_class)
65
+ rescue NameError => ex
66
+ case ex.message
67
+ when /uninitialized constant/
68
+ worker_class
69
+ else
70
+ raise
71
+ end
62
72
  end
63
73
 
64
74
  def mocked?
@@ -66,7 +76,7 @@ module SidekiqUniqueJobs
66
76
  end
67
77
 
68
78
  def redis_version
69
- @redis_version ||= connection { |c| c.info('server'.freeze)['redis_version'.freeze] }
79
+ @redis_version ||= connection { |conn| conn.info('server')['redis_version'] }
70
80
  end
71
81
 
72
82
  def connection(redis_pool = nil)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'thor'
2
4
 
3
5
  module SidekiqUniqueJobs
@@ -42,18 +44,18 @@ module SidekiqUniqueJobs
42
44
  console_class.start
43
45
  end
44
46
 
45
- private
46
-
47
- def logger
48
- SidekiqUniqueJobs.logger
49
- end
50
-
51
- def console_class
52
- require 'pry'
53
- Pry
54
- rescue LoadError
55
- require 'irb'
56
- IRB
47
+ no_commands do
48
+ def logger
49
+ SidekiqUniqueJobs.logger
50
+ end
51
+
52
+ def console_class
53
+ require 'pry'
54
+ Pry
55
+ rescue LoadError
56
+ require 'irb'
57
+ IRB
58
+ end
57
59
  end
58
60
  end
59
61
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'sidekiq_unique_jobs/server/middleware'
2
4
 
3
5
  module SidekiqUniqueJobs
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SidekiqUniqueJobs
2
4
  class Config < OpenStruct
3
5
  def inline_testing_enabled?
@@ -1,19 +1,22 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SidekiqUniqueJobs
2
- ARGS_KEY ||= 'args'.freeze
3
- AT_KEY ||= 'at'.freeze
4
- CLASS_KEY ||= 'class'.freeze
5
- JID_KEY ||= 'jid'.freeze
6
- LOG_DUPLICATE_KEY ||= 'log_duplicate_payload'.freeze
7
- QUEUE_KEY ||= 'queue'.freeze
8
- HASH_KEY ||= 'uniquejobs'.freeze
9
- QUEUE_LOCK_TIMEOUT_KEY ||= 'unique_expiration'.freeze
10
- RUN_LOCK_TIMEOUT_KEY ||= 'run_lock_expiration'.freeze
11
- TESTING_CONSTANT ||= 'Testing'.freeze
12
- UNIQUE_KEY ||= 'unique'.freeze
13
- UNIQUE_LOCK_KEY ||= 'unique_lock'.freeze
14
- UNIQUE_ARGS_KEY ||= 'unique_args'.freeze
15
- UNIQUE_PREFIX_KEY ||= 'unique_prefix'.freeze
16
- UNIQUE_DIGEST_KEY ||= 'unique_digest'.freeze
17
- UNIQUE_ON_ALL_QUEUES_KEY ||= 'unique_on_all_queues'.freeze
18
- UNIQUE_ARGS_ENABLED_KEY ||= 'unique_args_enabled'.freeze
4
+ ARGS_KEY ||= 'args'
5
+ AT_KEY ||= 'at'
6
+ CLASS_KEY ||= 'class'
7
+ JID_KEY ||= 'jid'
8
+ LOG_DUPLICATE_KEY ||= 'log_duplicate_payload'
9
+ QUEUE_KEY ||= 'queue'
10
+ HASH_KEY ||= 'uniquejobs'
11
+ QUEUE_LOCK_TIMEOUT_KEY ||= 'unique_expiration'
12
+ RUN_LOCK_TIMEOUT_KEY ||= 'run_lock_expiration'
13
+ TESTING_CONSTANT ||= 'Testing'
14
+ UNIQUE_KEY ||= 'unique'
15
+ UNIQUE_LOCK_KEY ||= 'unique_lock'
16
+ UNIQUE_ARGS_KEY ||= 'unique_args'
17
+ UNIQUE_PREFIX_KEY ||= 'unique_prefix'
18
+ UNIQUE_DIGEST_KEY ||= 'unique_digest'
19
+ UNIQUE_ON_ALL_QUEUES_KEY ||= 'unique_on_all_queues'
20
+ UNIQUE_ACROSS_WORKERS_KEY ||= 'unique_across_workers'
21
+ UNIQUE_ARGS_ENABLED_KEY ||= 'unique_args_enabled'
19
22
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  begin
2
4
  require 'active_support/core_ext/hash/keys'
3
5
  require 'active_support/core_ext/hash/deep_merge'
@@ -10,6 +12,22 @@ rescue LoadError
10
12
  end
11
13
  end
12
14
 
15
+ unless {}.respond_to?(:stringify_keys)
16
+ def stringify_keys
17
+ transform_keys(&:to_s)
18
+ end
19
+ end
20
+
21
+ unless {}.respond_to?(:transform_keys)
22
+ def transform_keys
23
+ result = {}
24
+ each_key do |key|
25
+ result[yield(key)] = self[key]
26
+ end
27
+ result
28
+ end
29
+ end
30
+
13
31
  unless {}.respond_to?(:slice!)
14
32
  def slice!(*keys)
15
33
  keys.map! { |key| convert_key(key) } if respond_to?(:convert_key, true)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SidekiqUniqueJobs
2
4
  module Lock
3
5
  class UntilAndWhileExecuting < UntilExecuting