sidekiq-unique-jobs 5.0.2 → 5.0.4

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 (201) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +4 -1
  3. data/Appraisals +1 -1
  4. data/CHANGELOG.md +9 -0
  5. data/CODE_OF_CONDUCT.md +74 -0
  6. data/Gemfile +1 -1
  7. data/LICENSE.txt +21 -0
  8. data/bin/bench +1 -1
  9. data/lib/sidekiq-unique-jobs.rb +3 -1
  10. data/lib/sidekiq/simulator.rb +4 -10
  11. data/lib/sidekiq_unique_jobs/cli.rb +2 -0
  12. data/lib/sidekiq_unique_jobs/client/middleware.rb +2 -0
  13. data/lib/sidekiq_unique_jobs/config.rb +2 -0
  14. data/lib/sidekiq_unique_jobs/constants.rb +19 -17
  15. data/lib/sidekiq_unique_jobs/core_ext.rb +2 -0
  16. data/lib/sidekiq_unique_jobs/lock.rb +2 -0
  17. data/lib/sidekiq_unique_jobs/lock/until_and_while_executing.rb +2 -0
  18. data/lib/sidekiq_unique_jobs/lock/until_executed.rb +3 -1
  19. data/lib/sidekiq_unique_jobs/lock/until_executing.rb +2 -0
  20. data/lib/sidekiq_unique_jobs/lock/until_timeout.rb +2 -0
  21. data/lib/sidekiq_unique_jobs/lock/while_executing.rb +2 -0
  22. data/lib/sidekiq_unique_jobs/middleware.rb +2 -0
  23. data/lib/sidekiq_unique_jobs/normalizer.rb +2 -0
  24. data/lib/sidekiq_unique_jobs/options_with_fallback.rb +2 -0
  25. data/lib/sidekiq_unique_jobs/run_lock_failed.rb +2 -0
  26. data/lib/sidekiq_unique_jobs/script_mock.rb +2 -0
  27. data/lib/sidekiq_unique_jobs/scripts.rb +15 -10
  28. data/lib/sidekiq_unique_jobs/scripts/acquire_lock.rb +2 -0
  29. data/lib/sidekiq_unique_jobs/scripts/release_lock.rb +2 -0
  30. data/lib/sidekiq_unique_jobs/server/middleware.rb +2 -0
  31. data/lib/sidekiq_unique_jobs/sidekiq_unique_ext.rb +2 -0
  32. data/lib/sidekiq_unique_jobs/testing.rb +2 -0
  33. data/lib/sidekiq_unique_jobs/testing/sidekiq_overrides.rb +2 -0
  34. data/lib/sidekiq_unique_jobs/timeout_calculator.rb +2 -0
  35. data/lib/sidekiq_unique_jobs/unique_args.rb +3 -1
  36. data/lib/sidekiq_unique_jobs/unlockable.rb +2 -0
  37. data/lib/sidekiq_unique_jobs/util.rb +5 -3
  38. data/lib/sidekiq_unique_jobs/version.rb +3 -1
  39. data/sidekiq-unique-jobs.gemspec +27 -23
  40. metadata +44 -200
  41. data/LICENSE +0 -13
  42. data/circle.yml +0 -41
  43. data/gemfiles/sidekiq_4.0.gemfile +0 -22
  44. data/gemfiles/sidekiq_4.1.gemfile +0 -22
  45. data/gemfiles/sidekiq_4.2.gemfile +0 -22
  46. data/gemfiles/sidekiq_5.0.gemfile +0 -22
  47. data/gemfiles/sidekiq_develop.gemfile +0 -22
  48. data/rails_example/.env +0 -12
  49. data/rails_example/.env.test +0 -12
  50. data/rails_example/.gitignore +0 -13
  51. data/rails_example/.rspec +0 -2
  52. data/rails_example/Gemfile +0 -38
  53. data/rails_example/Procfile +0 -2
  54. data/rails_example/README.rdoc +0 -28
  55. data/rails_example/Rakefile +0 -6
  56. data/rails_example/app/assets/images/.keep +0 -0
  57. data/rails_example/app/assets/javascripts/application.js +0 -16
  58. data/rails_example/app/assets/stylesheets/application.css +0 -15
  59. data/rails_example/app/channels/appearance_channel.rb +0 -17
  60. data/rails_example/app/channels/application_cable/channel.rb +0 -4
  61. data/rails_example/app/channels/application_cable/connection.rb +0 -9
  62. data/rails_example/app/channels/post_channel.rb +0 -5
  63. data/rails_example/app/controllers/application_controller.rb +0 -5
  64. data/rails_example/app/controllers/concerns/.keep +0 -0
  65. data/rails_example/app/controllers/work_controller.rb +0 -39
  66. data/rails_example/app/helpers/application_helper.rb +0 -2
  67. data/rails_example/app/mailers/.keep +0 -0
  68. data/rails_example/app/models/.keep +0 -0
  69. data/rails_example/app/models/application_record.rb +0 -3
  70. data/rails_example/app/models/concerns/.keep +0 -0
  71. data/rails_example/app/models/guest.rb +0 -18
  72. data/rails_example/app/models/post.rb +0 -2
  73. data/rails_example/app/views/layouts/application.html.erb +0 -15
  74. data/rails_example/app/workers/simple_worker.rb +0 -15
  75. data/rails_example/app/workers/slow_until_executing_worker.rb +0 -15
  76. data/rails_example/app/workers/spawn_simple_worker.rb +0 -10
  77. data/rails_example/app/workers/while_executing_worker.rb +0 -12
  78. data/rails_example/app/workers/without_args_worker.rb +0 -16
  79. data/rails_example/app/workers/without_argument_worker.rb +0 -12
  80. data/rails_example/bin/bundle +0 -3
  81. data/rails_example/bin/check_or_setup_db +0 -56
  82. data/rails_example/bin/docker-setup +0 -20
  83. data/rails_example/bin/rails +0 -4
  84. data/rails_example/bin/rake +0 -4
  85. data/rails_example/bin/setup +0 -34
  86. data/rails_example/bin/update +0 -29
  87. data/rails_example/cable.ru +0 -6
  88. data/rails_example/common-services.yml +0 -52
  89. data/rails_example/config.ru +0 -4
  90. data/rails_example/config/application.rb +0 -27
  91. data/rails_example/config/boot.rb +0 -3
  92. data/rails_example/config/cable.yml +0 -9
  93. data/rails_example/config/database.docker.yml +0 -12
  94. data/rails_example/config/database.yml +0 -19
  95. data/rails_example/config/environment.rb +0 -5
  96. data/rails_example/config/environments/development.rb +0 -54
  97. data/rails_example/config/environments/production.rb +0 -86
  98. data/rails_example/config/environments/test.rb +0 -42
  99. data/rails_example/config/initializers/application_controller_renderer.rb +0 -6
  100. data/rails_example/config/initializers/assets.rb +0 -11
  101. data/rails_example/config/initializers/backtrace_silencers.rb +0 -9
  102. data/rails_example/config/initializers/cookies_serializer.rb +0 -5
  103. data/rails_example/config/initializers/filter_parameter_logging.rb +0 -4
  104. data/rails_example/config/initializers/inflections.rb +0 -16
  105. data/rails_example/config/initializers/mime_types.rb +0 -4
  106. data/rails_example/config/initializers/new_framework_defaults.rb +0 -23
  107. data/rails_example/config/initializers/session_store.rb +0 -3
  108. data/rails_example/config/initializers/sidekiq.rb +0 -13
  109. data/rails_example/config/initializers/wrap_parameters.rb +0 -14
  110. data/rails_example/config/locales/en.yml +0 -23
  111. data/rails_example/config/puma.rb +0 -38
  112. data/rails_example/config/routes.rb +0 -8
  113. data/rails_example/config/secrets.yml +0 -22
  114. data/rails_example/config/sidekiq.yml +0 -6
  115. data/rails_example/config/spring.rb +0 -6
  116. data/rails_example/db/migrate/20160724111322_create_posts.rb +0 -12
  117. data/rails_example/db/schema.rb +0 -25
  118. data/rails_example/db/seeds.rb +0 -7
  119. data/rails_example/dev-entrypoint.sh +0 -55
  120. data/rails_example/dev.env +0 -12
  121. data/rails_example/docker-compose.yml +0 -71
  122. data/rails_example/docker/rails.Dockerfile +0 -27
  123. data/rails_example/lib/assets/.keep +0 -0
  124. data/rails_example/lib/tasks/.keep +0 -0
  125. data/rails_example/log/.keep +0 -0
  126. data/rails_example/public/404.html +0 -67
  127. data/rails_example/public/422.html +0 -67
  128. data/rails_example/public/500.html +0 -66
  129. data/rails_example/public/favicon.ico +0 -0
  130. data/rails_example/public/robots.txt +0 -5
  131. data/rails_example/simple.ru +0 -12
  132. data/rails_example/spec/controllers/work_controller_mock_spec.rb +0 -91
  133. data/rails_example/spec/controllers/work_controller_spec.rb +0 -77
  134. data/rails_example/spec/factories/posts.rb +0 -8
  135. data/rails_example/spec/models/post_spec.rb +0 -4
  136. data/rails_example/spec/rails_helper.rb +0 -20
  137. data/rails_example/spec/spec_helper.rb +0 -20
  138. data/rails_example/spec/support/sidekiq_meta.rb +0 -12
  139. data/rails_example/spec/workers/simple_worker_spec.rb +0 -4
  140. data/rails_example/vendor/assets/javascripts/.keep +0 -0
  141. data/rails_example/vendor/assets/stylesheets/.keep +0 -0
  142. data/spec/jobs/another_unique_job.rb +0 -13
  143. data/spec/jobs/custom_queue_job.rb +0 -5
  144. data/spec/jobs/custom_queue_job_with_filter_method.rb +0 -7
  145. data/spec/jobs/custom_queue_job_with_filter_proc.rb +0 -10
  146. data/spec/jobs/expiring_job.rb +0 -4
  147. data/spec/jobs/inline_worker.rb +0 -8
  148. data/spec/jobs/just_a_worker.rb +0 -7
  149. data/spec/jobs/long_running_job.rb +0 -6
  150. data/spec/jobs/main_job.rb +0 -7
  151. data/spec/jobs/my_job.rb +0 -12
  152. data/spec/jobs/my_unique_job.rb +0 -11
  153. data/spec/jobs/my_unique_job_with_filter_method.rb +0 -17
  154. data/spec/jobs/my_unique_job_with_filter_proc.rb +0 -15
  155. data/spec/jobs/notify_worker.rb +0 -10
  156. data/spec/jobs/plain_class.rb +0 -3
  157. data/spec/jobs/simple_worker.rb +0 -11
  158. data/spec/jobs/spawn_simple_worker.rb +0 -8
  159. data/spec/jobs/test_class.rb +0 -3
  160. data/spec/jobs/unique_job_with_conditional_parameter.rb +0 -14
  161. data/spec/jobs/unique_job_with_filter_method.rb +0 -18
  162. data/spec/jobs/unique_job_with_nil_unique_args.rb +0 -16
  163. data/spec/jobs/unique_job_with_no_unique_args_method.rb +0 -12
  164. data/spec/jobs/unique_job_withthout_unique_args_parameter.rb +0 -14
  165. data/spec/jobs/unique_on_all_queues_job.rb +0 -13
  166. data/spec/jobs/until_and_while_executing_job.rb +0 -7
  167. data/spec/jobs/until_executed_job.rb +0 -17
  168. data/spec/jobs/until_executing_job.rb +0 -7
  169. data/spec/jobs/until_global_timeout_job.rb +0 -8
  170. data/spec/jobs/until_timeout_job.rb +0 -8
  171. data/spec/jobs/while_executing_job.rb +0 -12
  172. data/spec/jobs/without_argument_job.rb +0 -9
  173. data/spec/lib/sidekiq_unique_jobs/cli_spec.rb +0 -183
  174. data/spec/lib/sidekiq_unique_jobs/client/middleware_spec.rb +0 -316
  175. data/spec/lib/sidekiq_unique_jobs/config_spec.rb +0 -84
  176. data/spec/lib/sidekiq_unique_jobs/core_ext_spec.rb +0 -25
  177. data/spec/lib/sidekiq_unique_jobs/lock/until_and_while_executing_spec.rb +0 -42
  178. data/spec/lib/sidekiq_unique_jobs/lock/until_executed_spec.rb +0 -37
  179. data/spec/lib/sidekiq_unique_jobs/lock/until_timeout_spec.rb +0 -26
  180. data/spec/lib/sidekiq_unique_jobs/lock/while_executing_spec.rb +0 -86
  181. data/spec/lib/sidekiq_unique_jobs/normalizer_spec.rb +0 -21
  182. data/spec/lib/sidekiq_unique_jobs/options_with_fallback_spec.rb +0 -113
  183. data/spec/lib/sidekiq_unique_jobs/queue_lock_timeout_calculator_spec.rb +0 -47
  184. data/spec/lib/sidekiq_unique_jobs/run_lock_timeout_calculator_spec.rb +0 -36
  185. data/spec/lib/sidekiq_unique_jobs/script_mock_spec.rb +0 -88
  186. data/spec/lib/sidekiq_unique_jobs/scripts/acquire_lock_spec.rb +0 -50
  187. data/spec/lib/sidekiq_unique_jobs/scripts/release_lock_spec.rb +0 -41
  188. data/spec/lib/sidekiq_unique_jobs/scripts_spec.rb +0 -68
  189. data/spec/lib/sidekiq_unique_jobs/server/middleware_spec.rb +0 -78
  190. data/spec/lib/sidekiq_unique_jobs/sidekiq_testing_enabled_spec.rb +0 -164
  191. data/spec/lib/sidekiq_unique_jobs/sidekiq_unique_ext_spec.rb +0 -75
  192. data/spec/lib/sidekiq_unique_jobs/sidekiq_unique_jobs_spec.rb +0 -41
  193. data/spec/lib/sidekiq_unique_jobs/timeout_calculator_spec.rb +0 -70
  194. data/spec/lib/sidekiq_unique_jobs/unique_args_spec.rb +0 -257
  195. data/spec/lib/sidekiq_unique_jobs/unlockable_spec.rb +0 -37
  196. data/spec/lib/sidekiq_unique_jobs/util_spec.rb +0 -81
  197. data/spec/spec_helper.rb +0 -92
  198. data/spec/support/matchers/redis_matchers.rb +0 -29
  199. data/spec/support/ruby_meta.rb +0 -17
  200. data/spec/support/sidekiq_meta.rb +0 -30
  201. data/spec/support/unique_macros.rb +0 -71
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4ca11c77223ec339ed2dba0bbfa3630c17db88df
4
- data.tar.gz: 8ac3ea5ed96f4303663cd7a43b3b70e93ece13c5
3
+ metadata.gz: 11b1c4aca9391461a5744ff361b1bd1d549a5d1e
4
+ data.tar.gz: d336770bd8f907edab6805a2f394b4d2bc26ef08
5
5
  SHA512:
6
- metadata.gz: ab6f325ea2633be2150c15f9441133901ec42fa767a5777328df8c44438fab1e8eddbb674a4f11132028899f7fab6c2a19dc1541dd9e2acea257e58bb96b3aca
7
- data.tar.gz: ece51ecdb1244507c06a5336d78106b92423b13d026d4c1f8a0ebadad778526522ce52efc7199b41530295fd2865f1732e53029ad929c51f70ef62ab944d79c3
6
+ metadata.gz: 87ac16889831fe0a6c072091cc4becc17e1e988867c8474788bf8f3d369ff2f6b83519b563080761727ffc13e9dd1b1559daf761779019fbcb1a8225c129299e
7
+ data.tar.gz: ecc7c5c08bfa9f2aab973e30d6ad3c044de0a8da5bd5a6b39c87273509b758795882c8a1ee0707d5c8fb31c776f725210dbe8029c9c96d8c13ca08478df5b643
data/.rubocop.yml CHANGED
@@ -42,7 +42,7 @@ Style/ConstantName:
42
42
  Enabled: true
43
43
 
44
44
  Style/FrozenStringLiteralComment:
45
- Enabled: false
45
+ Enabled: true
46
46
 
47
47
  Style/Documentation:
48
48
  Enabled: false
@@ -51,6 +51,9 @@ Style/FileName:
51
51
  Enabled: true
52
52
  Exclude:
53
53
  - 'lib/sidekiq-unique-jobs.rb'
54
+ - '**/Gemfile'
55
+ - '**/Appraisals'
56
+ - '**/*.gemspec'
54
57
 
55
58
  Style/GlobalVars:
56
59
  Enabled: true
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'
data/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ ## v5.0.4
2
+ - Fixes a problem with installing the gem
3
+
4
+ ## v5.0.3
5
+ - Removes test files and appraisals and such from the released gem version to speed up gem installs
6
+
7
+ ## v5.0.2
8
+ - Added more helpful debug, warning and error messages for failures to collect unique arghuments
9
+
1
10
  ## v5.0.1
2
11
 
3
12
  - 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,4 +1,4 @@
1
- # rubocop:disable Style/FileName
1
+ # frozen_string_literal: true
2
2
 
3
3
  source 'https://rubygems.org'
4
4
  gemspec
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/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 'yaml' if RUBY_VERSION.include?('2.0.0')
2
4
  require 'forwardable'
3
5
  require 'sidekiq_unique_jobs/version'
@@ -66,7 +68,7 @@ module SidekiqUniqueJobs
66
68
  end
67
69
 
68
70
  def redis_version
69
- @redis_version ||= connection { |c| c.info('server'.freeze)['redis_version'.freeze] }
71
+ @redis_version ||= connection { |c| c.info('server')['redis_version'] }
70
72
  end
71
73
 
72
74
  def connection(redis_pool = nil)
@@ -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 'thor'
2
4
 
3
5
  module SidekiqUniqueJobs
@@ -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,21 @@
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_ARGS_ENABLED_KEY ||= 'unique_args_enabled'
19
21
  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'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'sidekiq_unique_jobs/lock/until_executed'
2
4
  require 'sidekiq_unique_jobs/lock/until_executing'
3
5
  require 'sidekiq_unique_jobs/lock/while_executing'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SidekiqUniqueJobs
2
4
  module Lock
3
5
  class UntilAndWhileExecuting < UntilExecuting
@@ -1,7 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SidekiqUniqueJobs
2
4
  module Lock
3
5
  class UntilExecuted
4
- OK ||= 'OK'.freeze
6
+ OK ||= 'OK'
5
7
 
6
8
  include SidekiqUniqueJobs::Unlockable
7
9
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SidekiqUniqueJobs
2
4
  module Lock
3
5
  class UntilExecuting < UntilExecuted
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SidekiqUniqueJobs
2
4
  module Lock
3
5
  class UntilTimeout < UntilExecuted
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SidekiqUniqueJobs
2
4
  module Lock
3
5
  class WhileExecuting
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'sidekiq'
2
4
 
3
5
  module SidekiqUniqueJobs
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'json'
2
4
 
3
5
  module SidekiqUniqueJobs
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SidekiqUniqueJobs
2
4
  module OptionsWithFallback
3
5
  def self.included(base)
@@ -1 +1,3 @@
1
+ # frozen_string_literal: true
2
+
1
3
  SidekiqUniqueJobs::RunLockFailed = Class.new(StandardError)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'pathname'
2
4
  require 'digest/sha1'
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'pathname'
2
4
  require 'digest/sha1'
3
5
  require 'concurrent/map'
@@ -22,22 +24,25 @@ module SidekiqUniqueJobs
22
24
  extend SingleForwardable
23
25
  def_delegators :SidekiqUniqueJobs, :connection, :logger
24
26
 
25
- def call(file_name, redis_pool, options = {}) # rubocop:disable MethodLength
27
+ def call(file_name, redis_pool, options = {})
28
+ internal_call(file_name, redis_pool, options)
29
+ rescue Redis::CommandError => ex
30
+ handle_error(ex, file_name, redis_pool, options)
31
+ end
32
+
33
+ def internal_call(file_name, redis_pool, options = {})
26
34
  connection(redis_pool) do |redis|
27
- if SCRIPT_SHAS[file_name].nil?
28
- SCRIPT_SHAS[file_name] = redis.script(:load, script_source(file_name))
29
- end
35
+ SCRIPT_SHAS[file_name] = redis.script(:load, script_source(file_name)) if SCRIPT_SHAS[file_name].nil?
30
36
  redis.evalsha(SCRIPT_SHAS[file_name], options)
31
37
  end
32
- rescue Redis::CommandError => ex
33
- if ex.message == 'NOSCRIPT No matching script. Please use EVAL.'
38
+ end
39
+
40
+ def handle_error(ex, file_name, redis_pool, options = {})
41
+ if ex.message == 'NOSCRIPT No matching script. Please use EVAL.' # rubocop:disable Style/GuardClause
34
42
  SCRIPT_SHAS.delete(file_name)
35
43
  call(file_name, redis_pool, options)
36
- raise
37
44
  else
38
- raise ScriptError,
39
- "#{file_name}.lua\n\n#{ex.message}\n\n#{script_source(file_name)}" \
40
- "#{ex.backtrace.join("\n")}"
45
+ raise ScriptError, "Problem compiling #{file_name}. Invalid LUA syntax?"
41
46
  end
42
47
  end
43
48
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SidekiqUniqueJobs
2
4
  module Scripts
3
5
  class AcquireLock
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SidekiqUniqueJobs
2
4
  module Scripts
3
5
  class ReleaseLock
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SidekiqUniqueJobs
2
4
  module Server
3
5
  class Middleware
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'sidekiq/api'
2
4
 
3
5
  module Sidekiq
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'sidekiq_unique_jobs/testing/sidekiq_overrides'
2
4
  require 'sidekiq_unique_jobs/script_mock'
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'sidekiq/testing'
2
4
 
3
5
  module Sidekiq