sidekiq-unique-jobs 6.0.13 → 6.0.16

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 (76) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/lib/sidekiq_unique_jobs.rb +1 -0
  4. data/lib/sidekiq_unique_jobs/cli.rb +3 -1
  5. data/lib/sidekiq_unique_jobs/constants.rb +1 -0
  6. data/lib/sidekiq_unique_jobs/lock/until_and_while_executing.rb +20 -4
  7. data/lib/sidekiq_unique_jobs/locksmith.rb +2 -2
  8. data/lib/sidekiq_unique_jobs/logging.rb +5 -0
  9. data/lib/sidekiq_unique_jobs/middleware.rb +1 -1
  10. data/lib/sidekiq_unique_jobs/sidekiq_unique_jobs.rb +7 -3
  11. data/lib/sidekiq_unique_jobs/version.rb +1 -1
  12. data/lib/sidekiq_unique_jobs/version_check.rb +95 -0
  13. data/lib/sidekiq_unique_jobs/web.rb +4 -4
  14. data/lib/sidekiq_unique_jobs/web/helpers.rb +4 -4
  15. metadata +32 -74
  16. data/.codeclimate.yml +0 -32
  17. data/.editorconfig +0 -14
  18. data/.fasterer.yml +0 -23
  19. data/.github/ISSUE_TEMPLATE/bug_report.md +0 -31
  20. data/.github/ISSUE_TEMPLATE/feature_request.md +0 -17
  21. data/.gitignore +0 -17
  22. data/.mdlrc +0 -1
  23. data/.reek.yml +0 -88
  24. data/.rspec +0 -2
  25. data/.rubocop.yml +0 -159
  26. data/.simplecov +0 -20
  27. data/.travis.yml +0 -57
  28. data/.yardopts +0 -1
  29. data/Appraisals +0 -33
  30. data/CODE_OF_CONDUCT.md +0 -74
  31. data/Gemfile +0 -29
  32. data/Guardfile +0 -26
  33. data/Rakefile +0 -29
  34. data/_config.yml +0 -1
  35. data/assets/unique_digests_1.png +0 -0
  36. data/assets/unique_digests_2.png +0 -0
  37. data/bin/bench +0 -36
  38. data/examples/another_unique_job.rb +0 -15
  39. data/examples/custom_queue_job.rb +0 -12
  40. data/examples/custom_queue_job_with_filter_method.rb +0 -13
  41. data/examples/custom_queue_job_with_filter_proc.rb +0 -16
  42. data/examples/expiring_job.rb +0 -12
  43. data/examples/inline_worker.rb +0 -12
  44. data/examples/just_a_worker.rb +0 -13
  45. data/examples/long_running_job.rb +0 -14
  46. data/examples/main_job.rb +0 -14
  47. data/examples/my_job.rb +0 -12
  48. data/examples/my_unique_job.rb +0 -15
  49. data/examples/my_unique_job_with_filter_method.rb +0 -21
  50. data/examples/my_unique_job_with_filter_proc.rb +0 -19
  51. data/examples/notify_worker.rb +0 -14
  52. data/examples/plain_class.rb +0 -13
  53. data/examples/simple_worker.rb +0 -15
  54. data/examples/spawn_simple_worker.rb +0 -12
  55. data/examples/test_class.rb +0 -9
  56. data/examples/unique_across_workers_job.rb +0 -20
  57. data/examples/unique_job_on_conflict_raise.rb +0 -14
  58. data/examples/unique_job_on_conflict_reject.rb +0 -14
  59. data/examples/unique_job_on_conflict_reschedule.rb +0 -14
  60. data/examples/unique_job_with_conditional_parameter.rb +0 -18
  61. data/examples/unique_job_with_filter_method.rb +0 -21
  62. data/examples/unique_job_with_nil_unique_args.rb +0 -20
  63. data/examples/unique_job_with_no_unique_args_method.rb +0 -16
  64. data/examples/unique_job_withthout_unique_args_parameter.rb +0 -18
  65. data/examples/unique_on_all_queues_job.rb +0 -16
  66. data/examples/until_and_while_executing_job.rb +0 -17
  67. data/examples/until_executed_2_job.rb +0 -24
  68. data/examples/until_executed_job.rb +0 -25
  69. data/examples/until_executing_job.rb +0 -11
  70. data/examples/until_expired_job.rb +0 -12
  71. data/examples/until_global_expired_job.rb +0 -12
  72. data/examples/while_executing_job.rb +0 -15
  73. data/examples/while_executing_reject_job.rb +0 -14
  74. data/examples/without_argument_job.rb +0 -13
  75. data/sidekiq-unique-jobs.gemspec +0 -63
  76. data/update_docs.sh +0 -37
@@ -1,14 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # :nocov:
4
-
5
- class NotifyWorker
6
- include Sidekiq::Worker
7
-
8
- sidekiq_options lock: :until_executed,
9
- queue: :notify_worker
10
-
11
- def perform(pid, blob)
12
- [pid, blob]
13
- end
14
- end
@@ -1,13 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # :nocov:
4
-
5
- class PlainClass
6
- def self.run(one)
7
- [one]
8
- end
9
-
10
- def run(one)
11
- [one]
12
- end
13
- end
@@ -1,15 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # :nocov:
4
-
5
- class SimpleWorker
6
- include Sidekiq::Worker
7
- sidekiq_options lock: :until_executed,
8
- queue: :default,
9
- unique_args: ->(args) { [args.first] }
10
-
11
- def perform(args)
12
- sleep 5
13
- [args]
14
- end
15
- end
@@ -1,12 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # :nocov:
4
-
5
- class SpawnSimpleWorker
6
- include Sidekiq::Worker
7
- sidekiq_options queue: :not_default
8
-
9
- def perform(arg)
10
- SimpleWorker.perform_async arg
11
- end
12
- end
@@ -1,9 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # :nocov:
4
-
5
- class TestClass
6
- def self.run(one)
7
- one
8
- end
9
- end
@@ -1,20 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # :nocov:
4
-
5
- # This class showcase a job that is considered unique disregarding any worker classes.
6
- # Currently it will only be compared to other jobs that are disregarding worker classes.
7
- # If one were to compare the unique keys generated against a job that doesn't have the
8
- # worker class removed it won't work.
9
- #
10
- # The following specs cover this functionality:
11
- # - https://github.com/mhenrixon/sidekiq-unique-jobs/blob/master/spec/lib/sidekiq_unique_jobs/client/middleware_spec.rb
12
- # - https://github.com/mhenrixon/sidekiq-unique-jobs/blob/master/spec/lib/sidekiq_unique_jobs/unique_args_spec.rb
13
- class UniqueAcrossWorkersJob
14
- include Sidekiq::Worker
15
- sidekiq_options lock: :until_executed, unique_across_workers: true
16
-
17
- def perform(one, two)
18
- [one, two]
19
- end
20
- end
@@ -1,14 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # :nocov:
4
-
5
- class UniqueJobOnConflictRaise
6
- include Sidekiq::Worker
7
- sidekiq_options lock: :while_executing,
8
- queue: :customqueue,
9
- on_conflict: :raise
10
-
11
- def perform(one, two)
12
- [one, two]
13
- end
14
- end
@@ -1,14 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # :nocov:
4
-
5
- class UniqueJobOnConflictReject
6
- include Sidekiq::Worker
7
- sidekiq_options lock: :while_executing,
8
- queue: :customqueue,
9
- on_conflict: :reject
10
-
11
- def perform(one, two)
12
- [one, two]
13
- end
14
- end
@@ -1,14 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # :nocov:
4
-
5
- class UniqueJobOnConflictReschedule
6
- include Sidekiq::Worker
7
- sidekiq_options lock: :while_executing,
8
- queue: :customqueue,
9
- on_conflict: :reschedule
10
-
11
- def perform(one, two)
12
- [one, two]
13
- end
14
- end
@@ -1,18 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # :nocov:
4
-
5
- class UniqueJobWithoutUniqueArgsParameter
6
- include Sidekiq::Worker
7
- sidekiq_options backtrace: true,
8
- lock: :until_executed,
9
- queue: :customqueue,
10
- retry: true,
11
- unique_args: :unique_args
12
-
13
- def perform(conditional = nil)
14
- [conditional]
15
- end
16
-
17
- def self.unique_args; end
18
- end
@@ -1,21 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # :nocov:
4
-
5
- class UniqueJobWithFilterMethod
6
- include Sidekiq::Worker
7
- sidekiq_options backtrace: 10,
8
- lock: :while_executing,
9
- queue: :customqueue,
10
- retry: 1,
11
- unique_args: :filtered_args
12
-
13
- def perform(*)
14
- # NO-OP
15
- end
16
-
17
- def self.filtered_args(args)
18
- options = args.extract_options!
19
- [args.first, options["type"]]
20
- end
21
- end
@@ -1,20 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # :nocov:
4
-
5
- class UniqueJobWithNilUniqueArgs
6
- include Sidekiq::Worker
7
- sidekiq_options backtrace: true,
8
- lock: :until_executed,
9
- queue: :customqueue,
10
- retry: true,
11
- unique_args: :unique_args
12
-
13
- def perform(args)
14
- [args]
15
- end
16
-
17
- def self.unique_args(_args)
18
- nil
19
- end
20
- end
@@ -1,16 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # :nocov:
4
-
5
- class UniqueJobWithNoUniqueArgsMethod
6
- include Sidekiq::Worker
7
- sidekiq_options backtrace: true,
8
- lock: :until_executed,
9
- queue: :customqueue,
10
- retry: true,
11
- unique_args: :filtered_args
12
-
13
- def perform(one, two)
14
- [one, two]
15
- end
16
- end
@@ -1,18 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # :nocov:
4
-
5
- class UniqueJobWithoutUniqueArgsParameter
6
- include Sidekiq::Worker
7
- sidekiq_options backtrace: true,
8
- lock: :until_executed,
9
- queue: :customqueue,
10
- retry: true,
11
- unique_args: :unique_args
12
-
13
- def perform(optional = true)
14
- # NO-OP
15
- end
16
-
17
- def self.unique_args; end
18
- end
@@ -1,16 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # :nocov:
4
-
5
- # This class showcase a job that is considered unique disregarding any queue.
6
- # Currently it will only be compared to other jobs that are disregarding queue.
7
- # If one were to compare the unique keys generated against a job that doesn't have the
8
- # queue removed it won't work.
9
- class UniqueOnAllQueuesJob
10
- include Sidekiq::Worker
11
- sidekiq_options lock: :until_executed, unique_on_all_queues: true
12
-
13
- def perform(one, two, three = nil)
14
- [one, two, three]
15
- end
16
- end
@@ -1,17 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # :nocov:
4
-
5
- class UntilAndWhileExecutingJob
6
- include Sidekiq::Worker
7
-
8
- sidekiq_options lock: :until_and_while_executing,
9
- lock_expiration: nil,
10
- lock_timeout: 0,
11
- queue: :working
12
-
13
- def perform(sleepy_time)
14
- sleep(sleepy_time)
15
- [sleepy_time]
16
- end
17
- end
@@ -1,24 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # :nocov:
4
-
5
- # This class will lock until the job is successfully executed
6
- #
7
- # It will wait for 0 seconds to acquire a lock and it will expire the unique key after 2 seconds
8
- #
9
- class UntilExecuted2Job
10
- include Sidekiq::Worker
11
- sidekiq_options backtrace: 10,
12
- lock: :until_executed,
13
- lock_timeout: 0,
14
- queue: :working,
15
- retry: 1
16
-
17
- def perform(one, two)
18
- [one, two]
19
- end
20
-
21
- def after_unlock
22
- # NO OP
23
- end
24
- end
@@ -1,25 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # :nocov:
4
-
5
- # This class will lock until the job is successfully executed
6
- #
7
- # It will wait for 0 seconds to acquire a lock and it will expire the unique key after 2 seconds
8
- #
9
- class UntilExecutedJob
10
- include Sidekiq::Worker
11
- sidekiq_options backtrace: 10,
12
- lock: :until_executed,
13
- lock_expiration: 5_000,
14
- lock_timeout: 0,
15
- queue: :working,
16
- retry: 1
17
-
18
- def perform(one, two = nil)
19
- [one, two]
20
- end
21
-
22
- def after_unlock
23
- # NO OP
24
- end
25
- end
@@ -1,11 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # :nocov:
4
-
5
- class UntilExecutingJob
6
- include Sidekiq::Worker
7
-
8
- sidekiq_options lock: :until_executing, queue: :working
9
-
10
- def perform; end
11
- end
@@ -1,12 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # :nocov:
4
-
5
- class UntilExpiredJob
6
- include Sidekiq::Worker
7
- sidekiq_options lock: :until_expired, lock_expiration: 1, lock_timeout: 0
8
-
9
- def perform(one)
10
- TestClass.run(one)
11
- end
12
- end
@@ -1,12 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # :nocov:
4
-
5
- class UntilGlobalExpiredJob
6
- include Sidekiq::Worker
7
- sidekiq_options lock: :until_expired
8
-
9
- def perform(arg)
10
- TestClass.run(arg)
11
- end
12
- end
@@ -1,15 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # :nocov:
4
-
5
- class WhileExecutingJob
6
- include Sidekiq::Worker
7
- sidekiq_options backtrace: 10,
8
- lock: :while_executing,
9
- queue: :working,
10
- retry: 1
11
-
12
- def perform(args)
13
- [args]
14
- end
15
- end
@@ -1,14 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # :nocov:
4
-
5
- class WhileExecutingRejectJob
6
- include Sidekiq::Worker
7
- sidekiq_options lock: :while_executing_reject,
8
- queue: :rejecting
9
-
10
- def perform(args)
11
- sleep 5
12
- p args
13
- end
14
- end
@@ -1,13 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # :nocov:
4
-
5
- class WithoutArgumentJob
6
- include Sidekiq::Worker
7
- sidekiq_options lock: :until_executed,
8
- log_duplicate_payload: true
9
-
10
- def perform
11
- sleep 20
12
- end
13
- end
@@ -1,63 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- lib = File.expand_path("lib", __dir__)
4
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
-
6
- require "sidekiq_unique_jobs/version"
7
-
8
- Gem::Specification.new do |spec|
9
- spec.name = "sidekiq-unique-jobs"
10
- spec.version = SidekiqUniqueJobs::VERSION
11
- spec.authors = ["Mikael Henriksson"]
12
- spec.email = ["mikael@zoolutions.se"]
13
- spec.homepage = "https://mhenrixon.github.io/sidekiq-unique-jobs"
14
- spec.license = "MIT"
15
- spec.summary = <<~SUMMARY
16
- Sidekiq middleware that prevents duplicates jobs
17
- SUMMARY
18
- spec.description = <<~DESCRIPTION
19
- Prevents simultaneous Sidekiq jobs with the same unique arguments to run.
20
- Highly configurable to suite your specific needs.
21
- DESCRIPTION
22
-
23
- if spec.respond_to?(:metadata)
24
- spec.metadata["homepage_uri"] = spec.homepage
25
- spec.metadata["bug_tracker_uri"] = "https://github.com/mhenrixon/sidekiq-unique-jobs/issues"
26
- spec.metadata["documentation_uri"] = "https://mhenrixon.github.io/sidekiq-unique-jobs"
27
- spec.metadata["source_code_uri"] = "https://github.com/mhenrixon/sidekiq-unique-jobs"
28
- spec.metadata["changelog_uri"] = "https://github.com/mhenrixon/sidekiq-unique-jobs/CHANGELOG.md"
29
- else
30
- raise "RubyGems 2.0 or newer is required to protect against " \
31
- "public gem pushes."
32
- end
33
-
34
- spec.bindir = "bin"
35
- spec.executables = %w[uniquejobs]
36
-
37
- spec.files = Dir.chdir(File.expand_path(__dir__)) do
38
- `git ls-files -z`.split("\x0").reject do |file|
39
- file.match(%r{^(test|spec|features|gemfiles|pkg|rails_example|tmp)/})
40
- end
41
- end
42
-
43
- spec.require_paths = ["lib"]
44
- spec.add_dependency "concurrent-ruby", "~> 1.0", ">= 1.0.5"
45
- spec.add_dependency "sidekiq", ">= 4.0", "< 7.0"
46
- spec.add_dependency "thor", "~> 0"
47
-
48
- spec.add_development_dependency "bundler", ">= 2.0"
49
- spec.add_development_dependency "rack-test"
50
- spec.add_development_dependency "rake", "~> 12.3"
51
- spec.add_development_dependency "rspec", "~> 3.7"
52
- spec.add_development_dependency "sinatra"
53
- spec.add_development_dependency "timecop", "~> 0.9"
54
-
55
- # ===== Documentation =====
56
- spec.add_development_dependency "github-markup", "~> 3.0"
57
- spec.add_development_dependency "github_changelog_generator", "~> 1.14"
58
- # spec.add_development_dependency "redcarpet", "~> 3.4"
59
- spec.add_development_dependency "yard", "~> 0.9.18"
60
-
61
- # ===== Release Management =====
62
- spec.add_development_dependency "gem-release", ">= 2.0"
63
- end