From 6d31d935c0fb5e2c440b192f2d1bcec78900aea6 Mon Sep 17 00:00:00 2001 From: Mikael Henriksson Date: Thu, 25 Jul 2024 15:29:46 +0200 Subject: [PATCH] feat(digest): allow modern algorithm (#853) --- .github/workflows/rspec.yml | 1 + .rubocop.yml | 22 ++++- Appraisals | 4 + README.md | 35 +++++--- gemfiles/sidekiq_7.1.gemfile | 2 +- gemfiles/sidekiq_7.2.gemfile | 2 +- gemfiles/sidekiq_7.3.gemfile | 28 +++++++ lib/sidekiq_unique_jobs/config.rb | 80 ++++++++++++------- lib/sidekiq_unique_jobs/digests.rb | 2 +- lib/sidekiq_unique_jobs/exceptions.rb | 4 +- lib/sidekiq_unique_jobs/lock/base_lock.rb | 2 +- .../lock/while_executing.rb | 2 +- lib/sidekiq_unique_jobs/lock_args.rb | 6 +- lib/sidekiq_unique_jobs/lock_digest.rb | 7 +- lib/sidekiq_unique_jobs/locksmith.rb | 8 +- lib/sidekiq_unique_jobs/logging.rb | 4 +- lib/sidekiq_unique_jobs/on_conflict.rb | 4 +- .../on_conflict/replace.rb | 6 +- .../on_conflict/reschedule.rb | 2 +- lib/sidekiq_unique_jobs/orphans/manager.rb | 3 +- .../orphans/ruby_reaper.rb | 2 +- lib/sidekiq_unique_jobs/reflections.rb | 4 +- lib/sidekiq_unique_jobs/sidekiq_unique_ext.rb | 4 +- lib/sidekiq_unique_jobs/testing.rb | 2 +- .../until_and_while_executing_spec.rb | 12 +-- spec/performance/lock_digest_spec.rb | 4 +- spec/performance/locksmith_spec.rb | 4 +- spec/sidekiq_unique_jobs/cli_spec.rb | 6 +- spec/sidekiq_unique_jobs/config_spec.rb | 16 ++-- .../sidekiq_unique_jobs/configuration_spec.rb | 8 +- spec/sidekiq_unique_jobs/lock_args_spec.rb | 12 +-- spec/sidekiq_unique_jobs/lock_digest_spec.rb | 40 +++++++--- spec/sidekiq_unique_jobs/logging_spec.rb | 4 +- .../server/until_and_while_executing_spec.rb | 4 +- .../options_with_fallback_spec.rb | 2 +- .../script/scripts_spec.rb | 2 +- spec/sidekiq_unique_jobs/web_spec.rb | 12 +-- spec/support/jobs/another_unique_job_job.rb | 6 +- spec/support/workers/another_unique_job.rb | 6 +- .../custom_queue_job_with_filter_proc.rb | 6 +- spec/support/workers/long_running_job.rb | 6 +- spec/support/workers/main_job.rb | 2 +- spec/support/workers/my_unique_job.rb | 6 +- .../my_unique_job_with_filter_method.rb | 8 +- .../workers/my_unique_job_with_filter_proc.rb | 14 ++-- spec/support/workers/notify_worker.rb | 2 +- spec/support/workers/really_simple_worker.rb | 2 +- spec/support/workers/simple_worker.rb | 6 +- .../workers/unique_job_on_conflict_hash.rb | 4 +- .../workers/unique_job_on_conflict_raise.rb | 4 +- .../workers/unique_job_on_conflict_reject.rb | 4 +- .../workers/unique_job_on_conflict_replace.rb | 4 +- .../unique_job_on_conflict_reschedule.rb | 4 +- .../unique_job_with_conditional_parameter.rb | 8 +- .../workers/unique_job_with_filter_method.rb | 8 +- .../unique_job_with_nil_unique_args.rb | 8 +- .../unique_job_with_no_unique_args_method.rb | 8 +- ...nique_job_without_unique_args_parameter.rb | 8 +- .../workers/until_and_while_executing_job.rb | 6 +- ...until_and_while_executing_log_raise_job.rb | 12 +-- .../until_and_while_executing_reject_job.rb | 10 +-- .../until_and_while_executing_replace_job.rb | 10 +-- spec/support/workers/until_executed_2_job.rb | 8 +- spec/support/workers/until_executed_job.rb | 10 +-- spec/support/workers/while_executing_job.rb | 6 +- .../workers/while_executing_reject_job.rb | 2 +- .../workers/while_executing_reschedule_job.rb | 8 +- ...til_and_while_executing_reject_job_spec.rb | 4 +- ...il_and_while_executing_replace_job_spec.rb | 2 +- 69 files changed, 339 insertions(+), 225 deletions(-) create mode 100644 gemfiles/sidekiq_7.3.gemfile diff --git a/.github/workflows/rspec.yml b/.github/workflows/rspec.yml index bea0a85d8..e3a845eab 100644 --- a/.github/workflows/rspec.yml +++ b/.github/workflows/rspec.yml @@ -63,6 +63,7 @@ jobs: - sidekiq_7.0 - sidekiq_7.1 - sidekiq_7.2 + - sidekiq_7.3 steps: - uses: actions/checkout@v4 diff --git a/.rubocop.yml b/.rubocop.yml index 1eea75746..a59025c0e 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -27,10 +27,24 @@ AllCops: - "myapp/**/*" - "Sidekiq/**/*" - "vendor/**/*" +Layout/ArgumentAlignment: + Enabled: true + EnforcedStyle: with_fixed_indentation Layout/EndAlignment: EnforcedStyleAlignWith: variable +Layout/FirstArrayElementIndentation: + EnforcedStyle: consistent + +Layout/FirstHashElementIndentation: + EnforcedStyle: consistent + +Layout/HashAlignment: + EnforcedColonStyle: key + EnforcedHashRocketStyle: key + EnforcedLastArgumentHashStyle: always_inspect + Layout/LineContinuationLeadingSpace: Enabled: false @@ -115,7 +129,13 @@ RSpec/ExpectActual: RSpec/ExpectChange: EnforcedStyle: block -RSpec/FilePath: +RSpec/SpecFilePathFormat: + Enabled: true + Exclude: + - spec/performance/locksmith_spec.rb + - spec/performance/lock_digest_spec.rb + +RSpec/SpecFilePathSuffix: Enabled: true Exclude: - spec/performance/locksmith_spec.rb diff --git a/Appraisals b/Appraisals index cc63395ab..34d3512f5 100644 --- a/Appraisals +++ b/Appraisals @@ -15,3 +15,7 @@ end appraise "sidekiq-7.2" do gem "sidekiq", "~> 7.2.0" end + +appraise "sidekiq-7.3" do + gem "sidekiq", "~> 7.3.0" +end diff --git a/README.md b/README.md index ff3976fcd..358a65bd5 100644 --- a/README.md +++ b/README.md @@ -59,6 +59,7 @@ Want to show me some ❤️ for the hard work I do on this gem? You can use the - [sidekiq-global_id](#sidekiq-global_id) - [sidekiq-status](#sidekiq-status) - [Global Configuration](#global-configuration) + - [digest_algorithm](#digest_algorithm) - [debug_lua](#debug_lua) - [lock_timeout](#lock_timeout) - [lock_ttl](#lock_ttl) @@ -734,17 +735,29 @@ Configure SidekiqUniqueJobs in an initializer or the sidekiq initializer on appl ```ruby SidekiqUniqueJobs.configure do |config| - config.logger = Sidekiq.logger # default, change at your own discretion - config.logger_enabled = true # default, disable for test environments - config.debug_lua = false # Turn on when debugging - config.lock_info = false # Turn on when debugging - config.lock_ttl = 600 # Expire locks after 10 minutes - config.lock_timeout = nil # turn off lock timeout - config.max_history = 0 # Turn on when debugging - config.reaper = :ruby # :ruby, :lua or :none/nil - config.reaper_count = 1000 # Stop reaping after this many keys - config.reaper_interval = 600 # Reap orphans every 10 minutes - config.reaper_timeout = 150 # Timeout reaper after 2.5 minutes + config.logger = Sidekiq.logger # default, change at your own discretion + config.logger_enabled = true # default, disable for test environments + config.debug_lua = false # Turn on when debugging + config.lock_info = false # Turn on when debugging + config.lock_ttl = 600 # Expire locks after 10 minutes + config.lock_timeout = nil # turn off lock timeout + config.max_history = 0 # Turn on when debugging + config.reaper = :ruby # :ruby, :lua or :none/nil + config.reaper_count = 1000 # Stop reaping after this many keys + config.reaper_interval = 600 # Reap orphans every 10 minutes + config.reaper_timeout = 150 # Timeout reaper after 2.5 minutes + config.digest_algorithm = :modern # Timeout reaper after 2.5 minutes +end +``` +#### digest_algorithm + +For backwards compatibility this one is set to `:legacy` by the default. If you happen to run into issues with FIPS being enabled on your redis server you might want to set this to `:modern`. + +See: https://github.com/mhenrixon/sidekiq-unique-jobs/issues/848 for explanation + +```ruby +SidekiqUniqueJobs.configure do |config| + config.digest_algorithm = :modern # Timeout reaper after 2.5 minutes end ``` diff --git a/gemfiles/sidekiq_7.1.gemfile b/gemfiles/sidekiq_7.1.gemfile index 140999215..539a3be9a 100644 --- a/gemfiles/sidekiq_7.1.gemfile +++ b/gemfiles/sidekiq_7.1.gemfile @@ -19,7 +19,7 @@ gem "sinatra" gem "timecop" gem "toxiproxy" gem "yard" -gem "sidekiq", "~> 7.0.0" +gem "sidekiq", "~> 7.1.0" platforms :mri do gem "concurrent-ruby-ext" diff --git a/gemfiles/sidekiq_7.2.gemfile b/gemfiles/sidekiq_7.2.gemfile index 140999215..be782364c 100644 --- a/gemfiles/sidekiq_7.2.gemfile +++ b/gemfiles/sidekiq_7.2.gemfile @@ -19,7 +19,7 @@ gem "sinatra" gem "timecop" gem "toxiproxy" gem "yard" -gem "sidekiq", "~> 7.0.0" +gem "sidekiq", "~> 7.2.0" platforms :mri do gem "concurrent-ruby-ext" diff --git a/gemfiles/sidekiq_7.3.gemfile b/gemfiles/sidekiq_7.3.gemfile new file mode 100644 index 000000000..bc1012eb1 --- /dev/null +++ b/gemfiles/sidekiq_7.3.gemfile @@ -0,0 +1,28 @@ +# This file was generated by Appraisal + +source "https://rubygems.org" + +gem "appraisal" +gem "faraday-retry" +gem "gem-release" +gem "github-markup" +gem "rack-test" +gem "rake", "13.0.3" +gem "reek", ">= 5.3" +gem "rspec" +gem "rspec-benchmark" +gem "rspec-html-matchers" +gem "rspec-its" +gem "rubocop-mhenrixon" +gem "simplecov-sublime", ">= 0.21.2", require: false +gem "sinatra" +gem "timecop" +gem "toxiproxy" +gem "yard" +gem "sidekiq", "~> 7.3.0" + +platforms :mri do + gem "concurrent-ruby-ext" +end + +gemspec path: "../" diff --git a/lib/sidekiq_unique_jobs/config.rb b/lib/sidekiq_unique_jobs/config.rb index 23192823c..a8fbe96d4 100644 --- a/lib/sidekiq_unique_jobs/config.rb +++ b/lib/sidekiq_unique_jobs/config.rb @@ -2,26 +2,29 @@ module SidekiqUniqueJobs # ThreadSafe config exists to be able to document the config class without errors - ThreadSafeConfig = Concurrent::MutableStruct.new("ThreadSafeConfig", - :lock_timeout, - :lock_ttl, - :enabled, - :lock_prefix, - :logger, - :logger_enabled, - :locks, - :strategies, - :debug_lua, - :max_history, - :reaper, - :reaper_count, - :reaper_interval, - :reaper_timeout, - :reaper_resurrector_interval, - :reaper_resurrector_enabled, - :lock_info, - :raise_on_config_error, - :current_redis_version) + ThreadSafeConfig = Concurrent::MutableStruct.new( + "ThreadSafeConfig", + :lock_timeout, + :lock_ttl, + :enabled, + :lock_prefix, + :logger, + :logger_enabled, + :locks, + :strategies, + :debug_lua, + :max_history, + :reaper, + :reaper_count, + :reaper_interval, + :reaper_timeout, + :reaper_resurrector_interval, + :reaper_resurrector_enabled, + :lock_info, + :raise_on_config_error, + :current_redis_version, + :digest_algorithm, + ) # # Shared class for dealing with gem configuration @@ -118,11 +121,9 @@ class Config < ThreadSafeConfig # # @return [3600] check if reaper is dead each 3600 seconds REAPER_RESURRECTOR_INTERVAL = 3600 - # # @return [false] enable reaper resurrector REAPER_RESURRECTOR_ENABLED = false - # # @return [false] while useful it also adds overhead so disable lock_info by default USE_LOCK_INFO = false @@ -132,6 +133,9 @@ class Config < ThreadSafeConfig # # @return [0.0.0] default redis version is only to avoid NoMethodError on nil REDIS_VERSION = "0.0.0" + # + # @return [:legacy] default digest algorithm :modern or :legacy + DIGEST_ALGORITHM = :legacy # # Returns a default configuration @@ -198,6 +202,7 @@ def self.default # rubocop:disable Metrics/MethodLength USE_LOCK_INFO, RAISE_ON_CONFIG_ERROR, REDIS_VERSION, + DIGEST_ALGORITHM, ) end @@ -210,8 +215,8 @@ def self.default # rubocop:disable Metrics/MethodLength # @return [] # def default_lock_ttl=(obj) - warn "[DEPRECATION] `#{class_name}##{__method__}` is deprecated." \ - " Please use `#{class_name}#lock_ttl=` instead." + warn "[DEPRECATION] `#{class_name}##{__method__}` is deprecated. " \ + "Please use `#{class_name}#lock_ttl=` instead." self.lock_ttl = obj end @@ -224,8 +229,8 @@ def default_lock_ttl=(obj) # @return [Integer] # def default_lock_timeout=(obj) - warn "[DEPRECATION] `#{class_name}##{__method__}` is deprecated." \ - " Please use `#{class_name}#lock_timeout=` instead." + warn "[DEPRECATION] `#{class_name}##{__method__}` is deprecated. " \ + "Please use `#{class_name}#lock_timeout=` instead." self.lock_timeout = obj end @@ -236,8 +241,8 @@ def default_lock_timeout=(obj) # @return [nil, Integer] configured value or nil # def default_lock_ttl - warn "[DEPRECATION] `#{class_name}##{__method__}` is deprecated." \ - " Please use `#{class_name}#lock_ttl` instead." + warn "[DEPRECATION] `#{class_name}##{__method__}` is deprecated. " \ + "Please use `#{class_name}#lock_ttl` instead." lock_ttl end @@ -249,8 +254,8 @@ def default_lock_ttl # @return [nil, Integer] configured value or nil # def default_lock_timeout - warn "[DEPRECATION] `#{class_name}##{__method__}` is deprecated." \ - " Please use `#{class_name}#lock_timeout` instead." + warn "[DEPRECATION] `#{class_name}##{__method__}` is deprecated. " \ + "Please use `#{class_name}#lock_timeout` instead." lock_timeout end @@ -304,6 +309,21 @@ def add_strategy(name, klass) self.strategies = new_strategies end + # + # Sets digest_algorithm to either :modern or :legacy + # + # @param [Symbol] value + # + # @return [Symbol] the new value + # + def digest_algorithm=(value) + unless [:modern, :legacy].include?(value) + raise ArgumentError, "Invalid digest algorithm: #{value} (should be :modern or :legacy)" + end + + super + end + # # The current version of redis # diff --git a/lib/sidekiq_unique_jobs/digests.rb b/lib/sidekiq_unique_jobs/digests.rb index efab093f9..75ee059ed 100644 --- a/lib/sidekiq_unique_jobs/digests.rb +++ b/lib/sidekiq_unique_jobs/digests.rb @@ -18,7 +18,7 @@ class Digests < Redis::SortedSet EMPTY_KEYS_SEGMENT = ["", "", "", ""].freeze def initialize(digests_key = DIGESTS) - super(digests_key) + super end # diff --git a/lib/sidekiq_unique_jobs/exceptions.rb b/lib/sidekiq_unique_jobs/exceptions.rb index cb00f6be4..662069b60 100644 --- a/lib/sidekiq_unique_jobs/exceptions.rb +++ b/lib/sidekiq_unique_jobs/exceptions.rb @@ -80,8 +80,8 @@ def initialize(options) super( "#{job_class}##{lock_args_method} takes #{num_args} arguments, received #{given.inspect}" \ - "\n\n" \ - " #{source_location.join(':')}" + "\n\n " \ + "#{source_location.join(':')}" ) end end diff --git a/lib/sidekiq_unique_jobs/lock/base_lock.rb b/lib/sidekiq_unique_jobs/lock/base_lock.rb index 017db3091..d4a25bc37 100644 --- a/lib/sidekiq_unique_jobs/lock/base_lock.rb +++ b/lib/sidekiq_unique_jobs/lock/base_lock.rb @@ -147,7 +147,7 @@ def strategy_for(origin) server_strategy else raise SidekiqUniqueJobs::InvalidArgument, - "#origin needs to be either `:server` or `:client`" + "#origin needs to be either `:server` or `:client`" end end diff --git a/lib/sidekiq_unique_jobs/lock/while_executing.rb b/lib/sidekiq_unique_jobs/lock/while_executing.rb index 320061197..49961f7e4 100644 --- a/lib/sidekiq_unique_jobs/lock/while_executing.rb +++ b/lib/sidekiq_unique_jobs/lock/while_executing.rb @@ -23,7 +23,7 @@ class WhileExecuting < BaseLock # @param [Sidekiq::RedisConnection, ConnectionPool] redis_pool the redis connection # def initialize(item, callback, redis_pool = nil) - super(item, callback, redis_pool) + super append_unique_key_suffix end diff --git a/lib/sidekiq_unique_jobs/lock_args.rb b/lib/sidekiq_unique_jobs/lock_args.rb index 584931acf..6b1a0e15d 100644 --- a/lib/sidekiq_unique_jobs/lock_args.rb +++ b/lib/sidekiq_unique_jobs/lock_args.rb @@ -91,9 +91,9 @@ def filter_by_symbol(args) job_class.send(lock_args_method, args) rescue ArgumentError raise SidekiqUniqueJobs::InvalidUniqueArguments, - given: args, - job_class: job_class, - lock_args_method: lock_args_method + given: args, + job_class: job_class, + lock_args_method: lock_args_method end # The method to use for filtering unique arguments diff --git a/lib/sidekiq_unique_jobs/lock_digest.rb b/lib/sidekiq_unique_jobs/lock_digest.rb index c81ec76ea..2318b6606 100644 --- a/lib/sidekiq_unique_jobs/lock_digest.rb +++ b/lib/sidekiq_unique_jobs/lock_digest.rb @@ -51,7 +51,12 @@ def lock_digest # Creates a namespaced unique digest based on the {#digestable_hash} and the {#lock_prefix} # @return [String] a unique digest def create_digest - digest = OpenSSL::Digest::MD5.hexdigest(dump_json(digestable_hash.sort)) + digest = if SidekiqUniqueJobs.config.digest_algorithm == :legacy + OpenSSL::Digest::MD5.hexdigest(dump_json(digestable_hash.sort)) + else + OpenSSL::Digest.new("SHA3-256", dump_json(digestable_hash.sort)).hexdigest + end + "#{lock_prefix}:#{digest}" end diff --git a/lib/sidekiq_unique_jobs/locksmith.rb b/lib/sidekiq_unique_jobs/locksmith.rb index f3a177858..3ed5707ce 100644 --- a/lib/sidekiq_unique_jobs/locksmith.rb +++ b/lib/sidekiq_unique_jobs/locksmith.rb @@ -251,10 +251,10 @@ def primed_async(conn, wait = nil, &block) # rubocop:disable Metrics/MethodLengt concurrent_timeout = add_drift(timeout) reflect(:debug, :timeouts, item, - timeouts: { - brpoplpush_timeout: brpoplpush_timeout, - concurrent_timeout: concurrent_timeout, - }) + timeouts: { + brpoplpush_timeout: brpoplpush_timeout, + concurrent_timeout: concurrent_timeout, + }) # NOTE: When debugging, change .value to .value! primed_jid = Concurrent::Promises diff --git a/lib/sidekiq_unique_jobs/logging.rb b/lib/sidekiq_unique_jobs/logging.rb index 5dca48c14..529cb97ed 100644 --- a/lib/sidekiq_unique_jobs/logging.rb +++ b/lib/sidekiq_unique_jobs/logging.rb @@ -223,8 +223,8 @@ def no_sidekiq_context_method end def fake_logger_context(_context) - logger.warn "Don't know how to setup the logging context. Please open a feature request:" \ - " https://github.com/mhenrixon/sidekiq-unique-jobs/issues/new?template=feature_request.md" + logger.warn "Don't know how to setup the logging context. Please open a feature request: " \ + "https://github.com/mhenrixon/sidekiq-unique-jobs/issues/new?template=feature_request.md" yield end diff --git a/lib/sidekiq_unique_jobs/on_conflict.rb b/lib/sidekiq_unique_jobs/on_conflict.rb index 5e4ed49c3..0fc8f6153 100644 --- a/lib/sidekiq_unique_jobs/on_conflict.rb +++ b/lib/sidekiq_unique_jobs/on_conflict.rb @@ -33,8 +33,8 @@ def self.find_strategy(strategy) strategies.fetch(strategy.to_sym) do SidekiqUniqueJobs.logger.warn( - "No matching implementation for strategy: #{strategy}, returning OnConflict::NullStrategy." \ - " Available strategies are (#{strategies.inspect})", + "No matching implementation for strategy: #{strategy}, returning OnConflict::NullStrategy. " \ + "Available strategies are (#{strategies.inspect})", ) OnConflict::NullStrategy diff --git a/lib/sidekiq_unique_jobs/on_conflict/replace.rb b/lib/sidekiq_unique_jobs/on_conflict/replace.rb index 2c413085c..576df4496 100644 --- a/lib/sidekiq_unique_jobs/on_conflict/replace.rb +++ b/lib/sidekiq_unique_jobs/on_conflict/replace.rb @@ -21,7 +21,7 @@ class Replace < OnConflict::Strategy # @param [Hash] item sidekiq job hash # def initialize(item, redis_pool = nil) - super(item, redis_pool) + super @queue = item[QUEUE] @lock_digest = item[LOCK_DIGEST] end @@ -54,8 +54,8 @@ def call(&block) # def delete_job_by_digest call_script(:delete_job_by_digest, - keys: ["#{QUEUE}:#{queue}", SCHEDULE, RETRY], - argv: [lock_digest]) + keys: ["#{QUEUE}:#{queue}", SCHEDULE, RETRY], + argv: [lock_digest]) end # diff --git a/lib/sidekiq_unique_jobs/on_conflict/reschedule.rb b/lib/sidekiq_unique_jobs/on_conflict/reschedule.rb index 45f569c28..694b27cbe 100644 --- a/lib/sidekiq_unique_jobs/on_conflict/reschedule.rb +++ b/lib/sidekiq_unique_jobs/on_conflict/reschedule.rb @@ -13,7 +13,7 @@ class Reschedule < OnConflict::Strategy # @param [Hash] item sidekiq job hash def initialize(item, redis_pool = nil) - super(item, redis_pool) + super self.job_class = item[CLASS] end diff --git a/lib/sidekiq_unique_jobs/orphans/manager.rb b/lib/sidekiq_unique_jobs/orphans/manager.rb index 0cf0fa982..5774f7f23 100644 --- a/lib/sidekiq_unique_jobs/orphans/manager.rb +++ b/lib/sidekiq_unique_jobs/orphans/manager.rb @@ -32,7 +32,8 @@ module Manager # # @return [SidekiqUniqueJobs::TimerTask] the task that was started # - def start(test_task = nil) # rubocop:disable + # rubocop:disable + def start(test_task = nil) return if disabled? return if registered? diff --git a/lib/sidekiq_unique_jobs/orphans/ruby_reaper.rb b/lib/sidekiq_unique_jobs/orphans/ruby_reaper.rb index 76cc29947..d5a82ac8e 100644 --- a/lib/sidekiq_unique_jobs/orphans/ruby_reaper.rb +++ b/lib/sidekiq_unique_jobs/orphans/ruby_reaper.rb @@ -57,7 +57,7 @@ class RubyReaper < Reaper # @param [Redis] conn a connection to redis # def initialize(conn) - super(conn) + super @digests = SidekiqUniqueJobs::Digests.new @scheduled = Redis::SortedSet.new(SCHEDULE) @retried = Redis::SortedSet.new(RETRY) diff --git a/lib/sidekiq_unique_jobs/reflections.rb b/lib/sidekiq_unique_jobs/reflections.rb index 3bc9d91fc..30f389a04 100644 --- a/lib/sidekiq_unique_jobs/reflections.rb +++ b/lib/sidekiq_unique_jobs/reflections.rb @@ -57,8 +57,8 @@ def dispatch(reflection, *args) # rubocop:disable Metrics/MethodLength if DEPRECATIONS.key?(reflection) replacement, removal_version = DEPRECATIONS[reflection] SidekiqUniqueJobs::Deprecation.warn( - "#{reflection} is deprecated and will be removed in version #{removal_version}." \ - " Use #{replacement} instead.", + "#{reflection} is deprecated and will be removed in version #{removal_version}. " \ + "Use #{replacement} instead.", ) end elsif misconfigured?(reflection) diff --git a/lib/sidekiq_unique_jobs/sidekiq_unique_ext.rb b/lib/sidekiq_unique_jobs/sidekiq_unique_ext.rb index b003592a8..9c8778f6d 100644 --- a/lib/sidekiq_unique_jobs/sidekiq_unique_ext.rb +++ b/lib/sidekiq_unique_jobs/sidekiq_unique_ext.rb @@ -60,7 +60,7 @@ module UniqueExtension # def delete(score, job_id) entry = find_job(job_id) - SidekiqUniqueJobs::Unlockable.delete!(entry.item) if super(score, job_id) + SidekiqUniqueJobs::Unlockable.delete!(entry.item) if super entry end end @@ -132,7 +132,7 @@ def clear # @param [String] value a sidekiq job hash # def delete_by_value(name, value) - SidekiqUniqueJobs::Unlockable.delete!(Sidekiq.load_json(value)) if super(name, value) + SidekiqUniqueJobs::Unlockable.delete!(Sidekiq.load_json(value)) if super end end diff --git a/lib/sidekiq_unique_jobs/testing.rb b/lib/sidekiq_unique_jobs/testing.rb index a195b5050..9e4d80d05 100644 --- a/lib/sidekiq_unique_jobs/testing.rb +++ b/lib/sidekiq_unique_jobs/testing.rb @@ -87,7 +87,7 @@ module Overrides def sidekiq_options(options = {}) SidekiqUniqueJobs.validate_worker!(options) if SidekiqUniqueJobs.config.raise_on_config_error - super(options) + super end # diff --git a/spec/integration/until_and_while_executing_spec.rb b/spec/integration/until_and_while_executing_spec.rb index a179c6cc6..bf8953be7 100644 --- a/spec/integration/until_and_while_executing_spec.rb +++ b/spec/integration/until_and_while_executing_spec.rb @@ -9,12 +9,12 @@ Toxiproxy.host = ENV.fetch("TOXI_PROXY_HOST", "http://127.0.0.1:8474") Toxiproxy.populate([ - { - name: :redis, - listen: toxi_redis_url, - upstream: redis_url, - }, - ]) + { + name: :redis, + listen: toxi_redis_url, + upstream: redis_url, + }, + ]) Sidekiq::Testing.server_middleware do |chain| chain.add SidekiqUniqueJobs::Middleware::Server end diff --git a/spec/performance/lock_digest_spec.rb b/spec/performance/lock_digest_spec.rb index d6e681575..7160f5c49 100644 --- a/spec/performance/lock_digest_spec.rb +++ b/spec/performance/lock_digest_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -# rubocop:disable RSpec/SpecFilePathFormat, RSpec/FilePath +# rubocop:disable RSpec/SpecFilePathFormat RSpec.describe SidekiqUniqueJobs::LockDigest, :perf do let(:lock_digest) { described_class.new(item) } let(:job_class) { UntilExecutedJob } @@ -51,4 +51,4 @@ end end end -# rubocop:enable RSpec/SpecFilePathFormat, RSpec/FilePath +# rubocop:enable RSpec/SpecFilePathFormat diff --git a/spec/performance/locksmith_spec.rb b/spec/performance/locksmith_spec.rb index 792d7cf4d..772231905 100644 --- a/spec/performance/locksmith_spec.rb +++ b/spec/performance/locksmith_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -# rubocop:disable RSpec/SpecFilePathFormat, RSpec/FilePath +# rubocop:disable RSpec/SpecFilePathFormat RSpec.describe SidekiqUniqueJobs::Locksmith, :perf do let(:locksmith_one) { described_class.new(item_one) } let(:locksmith_two) { described_class.new(item_two) } @@ -46,4 +46,4 @@ expect { locksmith_one.unlock }.to perform_under(1).ms end end -# rubocop:enable RSpec/SpecFilePathFormat, RSpec/FilePath +# rubocop:enable RSpec/SpecFilePathFormat diff --git a/spec/sidekiq_unique_jobs/cli_spec.rb b/spec/sidekiq_unique_jobs/cli_spec.rb index 7c983b771..3a1313867 100644 --- a/spec/sidekiq_unique_jobs/cli_spec.rb +++ b/spec/sidekiq_unique_jobs/cli_spec.rb @@ -37,9 +37,9 @@ jobs del PATTERN Options: - -d, [--dry-run], [--no-dry-run] # set to false to perform deletion - -c, [--count=N] # The max number of digests to return - # Default: 1000 + -d, [--dry-run], [--no-dry-run], [--skip-dry-run] # set to false to perform deletion + -c, [--count=N] # The max number of digests to return + # Default: 1000 deletes unique digests from redis by pattern HEADER diff --git a/spec/sidekiq_unique_jobs/config_spec.rb b/spec/sidekiq_unique_jobs/config_spec.rb index 655f99e9a..a2f292d4b 100644 --- a/spec/sidekiq_unique_jobs/config_spec.rb +++ b/spec/sidekiq_unique_jobs/config_spec.rb @@ -15,8 +15,8 @@ it "warns about deprecation" do set_config expect(config).to have_received(:warn).with( - "[DEPRECATION] `SidekiqUniqueJobs::Config#default_lock_ttl=` is deprecated." \ - " Please use `SidekiqUniqueJobs::Config#lock_ttl=` instead.", + "[DEPRECATION] `SidekiqUniqueJobs::Config#default_lock_ttl=` is deprecated. " \ + "Please use `SidekiqUniqueJobs::Config#lock_ttl=` instead.", ) expect(config.lock_ttl).to eq(new_value) end @@ -34,8 +34,8 @@ it "warns about deprecation" do set_config expect(config).to have_received(:warn).with( - "[DEPRECATION] `SidekiqUniqueJobs::Config#default_lock_timeout=` is deprecated." \ - " Please use `SidekiqUniqueJobs::Config#lock_timeout=` instead.", + "[DEPRECATION] `SidekiqUniqueJobs::Config#default_lock_timeout=` is deprecated. " \ + "Please use `SidekiqUniqueJobs::Config#lock_timeout=` instead.", ) expect(config.lock_timeout).to eq(new_value) end @@ -51,8 +51,8 @@ it "warns about deprecation" do get_config expect(config).to have_received(:warn).with( - "[DEPRECATION] `SidekiqUniqueJobs::Config#default_lock_ttl` is deprecated." \ - " Please use `SidekiqUniqueJobs::Config#lock_ttl` instead.", + "[DEPRECATION] `SidekiqUniqueJobs::Config#default_lock_ttl` is deprecated. " \ + "Please use `SidekiqUniqueJobs::Config#lock_ttl` instead.", ) expect(config.lock_ttl).to eq(get_config) end @@ -68,8 +68,8 @@ it "warns about deprecation" do get_config expect(config).to have_received(:warn).with( - "[DEPRECATION] `SidekiqUniqueJobs::Config#default_lock_timeout` is deprecated." \ - " Please use `SidekiqUniqueJobs::Config#lock_timeout` instead.", + "[DEPRECATION] `SidekiqUniqueJobs::Config#default_lock_timeout` is deprecated. " \ + "Please use `SidekiqUniqueJobs::Config#lock_timeout` instead.", ) expect(config.lock_timeout).to eq(get_config) end diff --git a/spec/sidekiq_unique_jobs/configuration_spec.rb b/spec/sidekiq_unique_jobs/configuration_spec.rb index 9434fb060..fc45e3d04 100644 --- a/spec/sidekiq_unique_jobs/configuration_spec.rb +++ b/spec/sidekiq_unique_jobs/configuration_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -# rubocop:disable RSpec/SpecFilePathFormat, RSpec/FilePath +# rubocop:disable RSpec/SpecFilePathFormat RSpec.describe SidekiqUniqueJobs do describe "define custom lock strategies" do subject(:middleware_call) do @@ -12,8 +12,8 @@ let(:foobar_job) do Class.new(MyJob) do sidekiq_options lock: :foobar, - queue: :customqueue, - on_conflict: :raise + queue: :customqueue, + on_conflict: :raise end end @@ -65,4 +65,4 @@ def lock end end end -# rubocop:enable RSpec/SpecFilePathFormat, RSpec/FilePath +# rubocop:enable RSpec/SpecFilePathFormat diff --git a/spec/sidekiq_unique_jobs/lock_args_spec.rb b/spec/sidekiq_unique_jobs/lock_args_spec.rb index a95ca06e3..860949bb5 100644 --- a/spec/sidekiq_unique_jobs/lock_args_spec.rb +++ b/spec/sidekiq_unique_jobs/lock_args_spec.rb @@ -108,8 +108,8 @@ .to raise_error( SidekiqUniqueJobs::InvalidUniqueArguments, a_string_starting_with( - "UniqueJobWithoutUniqueArgsParameter#unique_args takes 0 arguments," \ - " received [1]", + "UniqueJobWithoutUniqueArgsParameter#unique_args takes 0 arguments, " \ + "received [1]", ), ) end @@ -122,8 +122,8 @@ .to raise_error( SidekiqUniqueJobs::InvalidUniqueArguments, a_string_starting_with( - "UniqueJobWithoutUniqueArgsParameter#unique_args takes 0 arguments," \ - " received []", + "UniqueJobWithoutUniqueArgsParameter#unique_args takes 0 arguments, " \ + "received []", ), ) end @@ -139,8 +139,8 @@ .to raise_error( SidekiqUniqueJobs::InvalidUniqueArguments, a_string_starting_with( - 'UniqueJobWithoutUniqueArgsParameter#unique_args takes 0 arguments,' \ - ' received ["name", 2, {"whatever"=>nil, "type"=>"test"}]', \ + 'UniqueJobWithoutUniqueArgsParameter#unique_args takes 0 arguments, ' \ + 'received ["name", 2, {"whatever"=>nil, "type"=>"test"}]', \ ), ) end diff --git a/spec/sidekiq_unique_jobs/lock_digest_spec.rb b/spec/sidekiq_unique_jobs/lock_digest_spec.rb index 1187874d6..2e50cf8c5 100644 --- a/spec/sidekiq_unique_jobs/lock_digest_spec.rb +++ b/spec/sidekiq_unique_jobs/lock_digest_spec.rb @@ -35,7 +35,7 @@ let(:digest_two) { described_class.new(another_item) } context "with the same unique args" do - let(:another_item) { item } + let(:another_item) { item.dup } it "equals to lock_digest for that item" do expect(lock_digest).to eq(digest_two.lock_digest) @@ -52,18 +52,40 @@ end end - context "when digest is a proc" do - let(:job_class) { MyUniqueJobWithFilterProc } - let(:args) { [1, 2, { "type" => "it" }] } + context "when digest_algorithm is :legacy" do + context "when digest is a proc" do + let(:job_class) { MyUniqueJobWithFilterProc } + let(:args) { [1, 2, { "type" => "it" }] } - it_behaves_like "unique digest" + it_behaves_like "unique digest" + end + + context "when unique_args is a symbol" do + let(:job_class) { MyUniqueJobWithFilterMethod } + let(:args) { [1, 2, { "type" => "it" }] } + + it_behaves_like "unique digest" + end end - context "when unique_args is a symbol" do - let(:job_class) { MyUniqueJobWithFilterMethod } - let(:args) { [1, 2, { "type" => "it" }] } + context "when digest_algorithm is :modern" do + around do |example| + SidekiqUniqueJobs.use_config(digest_algorithm: :modern, &example) + end + + context "when digest is a proc" do + let(:job_class) { MyUniqueJobWithFilterProc } + let(:args) { [1, 2, { "type" => "it" }] } + + it_behaves_like "unique digest" + end - it_behaves_like "unique digest" + context "when unique_args is a symbol" do + let(:job_class) { MyUniqueJobWithFilterMethod } + let(:args) { [1, 2, { "type" => "it" }] } + + it_behaves_like "unique digest" + end end end diff --git a/spec/sidekiq_unique_jobs/logging_spec.rb b/spec/sidekiq_unique_jobs/logging_spec.rb index 6451db471..472d9b9d7 100644 --- a/spec/sidekiq_unique_jobs/logging_spec.rb +++ b/spec/sidekiq_unique_jobs/logging_spec.rb @@ -177,8 +177,8 @@ def self.with_context(_msg) with_configured_loggers_context {} expect(logger).to have_received(:warn).with( - "Don't know how to setup the logging context. Please open a feature request:" \ - " https://github.com/mhenrixon/sidekiq-unique-jobs/issues/new?template=feature_request.md", + "Don't know how to setup the logging context. Please open a feature request: " \ + "https://github.com/mhenrixon/sidekiq-unique-jobs/issues/new?template=feature_request.md", ) end end diff --git a/spec/sidekiq_unique_jobs/middleware/server/until_and_while_executing_spec.rb b/spec/sidekiq_unique_jobs/middleware/server/until_and_while_executing_spec.rb index 57ed68250..499f8b285 100644 --- a/spec/sidekiq_unique_jobs/middleware/server/until_and_while_executing_spec.rb +++ b/spec/sidekiq_unique_jobs/middleware/server/until_and_while_executing_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -# rubocop:disable RSpec/SpecFilePathFormat, RSpec/FilePath, RSpec/DescribeMethod +# rubocop:disable RSpec/SpecFilePathFormat, RSpec/DescribeMethod RSpec.describe SidekiqUniqueJobs::Middleware::Server, "lock: :until_and_while_executing" do let(:server) { described_class.new } @@ -46,4 +46,4 @@ end end end -# rubocop:enable RSpec/SpecFilePathFormat, RSpec/FilePath, RSpec/DescribeMethod +# rubocop:enable RSpec/SpecFilePathFormat, RSpec/DescribeMethod diff --git a/spec/sidekiq_unique_jobs/options_with_fallback_spec.rb b/spec/sidekiq_unique_jobs/options_with_fallback_spec.rb index 83d30e390..892ea9fae 100644 --- a/spec/sidekiq_unique_jobs/options_with_fallback_spec.rb +++ b/spec/sidekiq_unique_jobs/options_with_fallback_spec.rb @@ -130,7 +130,7 @@ def initialize(item, options, job_class = nil) it do expect { lock_class } .to raise_error(SidekiqUniqueJobs::UnknownLock, - "No implementation for `lock: :until_unknown`") + "No implementation for `lock: :until_unknown`") end end end diff --git a/spec/sidekiq_unique_jobs/script/scripts_spec.rb b/spec/sidekiq_unique_jobs/script/scripts_spec.rb index f9c679eab..a3c8a096d 100644 --- a/spec/sidekiq_unique_jobs/script/scripts_spec.rb +++ b/spec/sidekiq_unique_jobs/script/scripts_spec.rb @@ -59,6 +59,6 @@ describe "#kill" do subject(:kill) { scripts.kill(redis) } - specify { expect { kill }.to raise_error(RedisClient::CommandError, "NOTBUSY No scripts in execution right now.") } + specify { expect { kill }.to raise_error(RedisClient::CommandError, /NOTBUSY/) } end end diff --git a/spec/sidekiq_unique_jobs/web_spec.rb b/spec/sidekiq_unique_jobs/web_spec.rb index a84744a91..6ce90e69c 100644 --- a/spec/sidekiq_unique_jobs/web_spec.rb +++ b/spec/sidekiq_unique_jobs/web_spec.rb @@ -12,12 +12,12 @@ def app @app ||= Rack::Builder.new do use Rack::Session::Cookie, - key: "rack.session", - domain: "foo.com", - path: "/", - expire_after: 2_592_000, - secret: "change_me" * 10, - old_secret: "also_change_me" * 10 + key: "rack.session", + domain: "foo.com", + path: "/", + expire_after: 2_592_000, + secret: "change_me" * 10, + old_secret: "also_change_me" * 10 run Sidekiq::Web end diff --git a/spec/support/jobs/another_unique_job_job.rb b/spec/support/jobs/another_unique_job_job.rb index ee155d441..a4e919a8e 100644 --- a/spec/support/jobs/another_unique_job_job.rb +++ b/spec/support/jobs/another_unique_job_job.rb @@ -6,9 +6,9 @@ class AnotherUniqueJobJob include Sidekiq::Job sidekiq_options backtrace: 10, - lock: :until_executed, - queue: :working2, - retry: 1 + lock: :until_executed, + queue: :working2, + retry: 1 def perform(args) args diff --git a/spec/support/workers/another_unique_job.rb b/spec/support/workers/another_unique_job.rb index 45e85497c..f1b96de57 100644 --- a/spec/support/workers/another_unique_job.rb +++ b/spec/support/workers/another_unique_job.rb @@ -5,9 +5,9 @@ class AnotherUniqueJob include Sidekiq::Job sidekiq_options backtrace: 10, - lock: :until_executed, - queue: :working2, - retry: 1 + lock: :until_executed, + queue: :working2, + retry: 1 def perform(args) args diff --git a/spec/support/workers/custom_queue_job_with_filter_proc.rb b/spec/support/workers/custom_queue_job_with_filter_proc.rb index 75dd90b84..7bf805d0c 100644 --- a/spec/support/workers/custom_queue_job_with_filter_proc.rb +++ b/spec/support/workers/custom_queue_job_with_filter_proc.rb @@ -8,7 +8,7 @@ class CustomQueueJobWithFilterProc < CustomQueueJob # slightly contrived example of munging args to the # worker and removing a random bit. sidekiq_options lock: :until_expired, - lock_args_method: (lambda do |args| - [args[0], args[1]["name"]] - end) + lock_args_method: (lambda do |args| + [args[0], args[1]["name"]] + end) end diff --git a/spec/support/workers/long_running_job.rb b/spec/support/workers/long_running_job.rb index 05a68f4fc..23f6860b1 100644 --- a/spec/support/workers/long_running_job.rb +++ b/spec/support/workers/long_running_job.rb @@ -5,9 +5,9 @@ class LongRunningJob include Sidekiq::Worker sidekiq_options lock: :until_and_while_executing, - lock_ttl: 7_200, - queue: :customqueue, - retry: 10 + lock_ttl: 7_200, + queue: :customqueue, + retry: 10 def perform(one, two) [one, two] end diff --git a/spec/support/workers/main_job.rb b/spec/support/workers/main_job.rb index ea0e7904d..92350f627 100644 --- a/spec/support/workers/main_job.rb +++ b/spec/support/workers/main_job.rb @@ -5,7 +5,7 @@ class MainJob include Sidekiq::Worker sidekiq_options lock: :until_executed, - queue: :customqueue + queue: :customqueue def perform(arg) [arg] diff --git a/spec/support/workers/my_unique_job.rb b/spec/support/workers/my_unique_job.rb index 415ee39d1..d59817768 100644 --- a/spec/support/workers/my_unique_job.rb +++ b/spec/support/workers/my_unique_job.rb @@ -5,9 +5,9 @@ class MyUniqueJob include Sidekiq::Worker sidekiq_options lock: :until_executed, - lock_ttl: 7_200, - queue: :customqueue, - retry: 10 + lock_ttl: 7_200, + queue: :customqueue, + retry: 10 def perform(one, two) [one, two] diff --git a/spec/support/workers/my_unique_job_with_filter_method.rb b/spec/support/workers/my_unique_job_with_filter_method.rb index 0ba82b9f7..579badf60 100644 --- a/spec/support/workers/my_unique_job_with_filter_method.rb +++ b/spec/support/workers/my_unique_job_with_filter_method.rb @@ -5,10 +5,10 @@ class MyUniqueJobWithFilterMethod include Sidekiq::Worker sidekiq_options backtrace: true, - lock: :until_executed, - queue: :customqueue, - retry: true, - lock_args_method: :lock_args + lock: :until_executed, + queue: :customqueue, + retry: true, + lock_args_method: :lock_args def perform(*) # NO-OP diff --git a/spec/support/workers/my_unique_job_with_filter_proc.rb b/spec/support/workers/my_unique_job_with_filter_proc.rb index f8e8c9e8c..0a4da14a0 100644 --- a/spec/support/workers/my_unique_job_with_filter_proc.rb +++ b/spec/support/workers/my_unique_job_with_filter_proc.rb @@ -5,13 +5,13 @@ class MyUniqueJobWithFilterProc include Sidekiq::Worker sidekiq_options backtrace: true, - lock: :until_executed, - queue: :customqueue, - retry: true, - lock_args_method: (lambda do |args| - options = args.extract_options! - [args.first, options["type"]] - end) + lock: :until_executed, + queue: :customqueue, + retry: true, + lock_args_method: (lambda do |args| + options = args.extract_options! + [args.first, options["type"]] + end) def perform(*) # NO-OP diff --git a/spec/support/workers/notify_worker.rb b/spec/support/workers/notify_worker.rb index 8ed8f65a0..e9f3f1781 100644 --- a/spec/support/workers/notify_worker.rb +++ b/spec/support/workers/notify_worker.rb @@ -6,7 +6,7 @@ class NotifyWorker include Sidekiq::Worker sidekiq_options lock: :until_executed, - queue: :notify_worker + queue: :notify_worker def perform(pid, blob) [pid, blob] diff --git a/spec/support/workers/really_simple_worker.rb b/spec/support/workers/really_simple_worker.rb index be939997e..7774236c2 100644 --- a/spec/support/workers/really_simple_worker.rb +++ b/spec/support/workers/really_simple_worker.rb @@ -5,7 +5,7 @@ class ReallySimpleWorker include Sidekiq::Worker sidekiq_options lock: :until_executed, - queue: :bogus + queue: :bogus def perform(args) sleep 5 diff --git a/spec/support/workers/simple_worker.rb b/spec/support/workers/simple_worker.rb index baaf6b084..f4acabe38 100644 --- a/spec/support/workers/simple_worker.rb +++ b/spec/support/workers/simple_worker.rb @@ -6,9 +6,9 @@ class SimpleWorker include Sidekiq::Worker sidekiq_options backtrace: true, - lock: :until_executed, - queue: :default, - lock_args_method: ->(args) { [args.first] } + lock: :until_executed, + queue: :default, + lock_args_method: ->(args) { [args.first] } def perform(args) sleep 5 diff --git a/spec/support/workers/unique_job_on_conflict_hash.rb b/spec/support/workers/unique_job_on_conflict_hash.rb index 07b00572d..0bbd6d71e 100644 --- a/spec/support/workers/unique_job_on_conflict_hash.rb +++ b/spec/support/workers/unique_job_on_conflict_hash.rb @@ -6,8 +6,8 @@ class UniqueJobOnConflictHash include Sidekiq::Worker sidekiq_options lock: :until_and_while_executing, - queue: :customqueue, - on_conflict: { client: :log, server: :reschedule } + queue: :customqueue, + on_conflict: { client: :log, server: :reschedule } def perform(one, two) [one, two] diff --git a/spec/support/workers/unique_job_on_conflict_raise.rb b/spec/support/workers/unique_job_on_conflict_raise.rb index a23993d0d..05a278974 100644 --- a/spec/support/workers/unique_job_on_conflict_raise.rb +++ b/spec/support/workers/unique_job_on_conflict_raise.rb @@ -5,8 +5,8 @@ class UniqueJobOnConflictRaise include Sidekiq::Worker sidekiq_options lock: :while_executing, - queue: :customqueue, - on_conflict: :raise + queue: :customqueue, + on_conflict: :raise def perform(one, two) [one, two] diff --git a/spec/support/workers/unique_job_on_conflict_reject.rb b/spec/support/workers/unique_job_on_conflict_reject.rb index 2bdf4d686..ae2f76b75 100644 --- a/spec/support/workers/unique_job_on_conflict_reject.rb +++ b/spec/support/workers/unique_job_on_conflict_reject.rb @@ -5,8 +5,8 @@ class UniqueJobOnConflictReject include Sidekiq::Worker sidekiq_options lock: :while_executing, - queue: :customqueue, - on_conflict: :reject + queue: :customqueue, + on_conflict: :reject def perform(one, two) [one, two] diff --git a/spec/support/workers/unique_job_on_conflict_replace.rb b/spec/support/workers/unique_job_on_conflict_replace.rb index 64c6a5631..1eadd2b46 100644 --- a/spec/support/workers/unique_job_on_conflict_replace.rb +++ b/spec/support/workers/unique_job_on_conflict_replace.rb @@ -5,8 +5,8 @@ class UniqueJobOnConflictReplace include Sidekiq::Worker sidekiq_options lock: :until_executing, - queue: :customqueue, - on_conflict: :replace + queue: :customqueue, + on_conflict: :replace def perform(one, two) [one, two] diff --git a/spec/support/workers/unique_job_on_conflict_reschedule.rb b/spec/support/workers/unique_job_on_conflict_reschedule.rb index afe54da60..1e683cc41 100644 --- a/spec/support/workers/unique_job_on_conflict_reschedule.rb +++ b/spec/support/workers/unique_job_on_conflict_reschedule.rb @@ -5,8 +5,8 @@ class UniqueJobOnConflictReschedule include Sidekiq::Worker sidekiq_options lock: :while_executing, - queue: :customqueue, - on_conflict: :reschedule + queue: :customqueue, + on_conflict: :reschedule def perform(one, two) [one, two] diff --git a/spec/support/workers/unique_job_with_conditional_parameter.rb b/spec/support/workers/unique_job_with_conditional_parameter.rb index dd3e56bb9..ad9a8ea6e 100644 --- a/spec/support/workers/unique_job_with_conditional_parameter.rb +++ b/spec/support/workers/unique_job_with_conditional_parameter.rb @@ -5,10 +5,10 @@ class UniqueJobWithoutUniqueArgsParameter include Sidekiq::Worker sidekiq_options backtrace: true, - lock: :until_executed, - queue: :customqueue, - retry: true, - lock_args_method: :unique_args + lock: :until_executed, + queue: :customqueue, + retry: true, + lock_args_method: :unique_args def perform(conditional = nil) [conditional] diff --git a/spec/support/workers/unique_job_with_filter_method.rb b/spec/support/workers/unique_job_with_filter_method.rb index 13bb4ee18..0b39eff3f 100644 --- a/spec/support/workers/unique_job_with_filter_method.rb +++ b/spec/support/workers/unique_job_with_filter_method.rb @@ -5,10 +5,10 @@ class UniqueJobWithFilterMethod include Sidekiq::Worker sidekiq_options backtrace: 10, - lock: :while_executing, - queue: :customqueue, - retry: 1, - lock_args_method: :lock_args + lock: :while_executing, + queue: :customqueue, + retry: 1, + lock_args_method: :lock_args def perform(*) # NO-OP diff --git a/spec/support/workers/unique_job_with_nil_unique_args.rb b/spec/support/workers/unique_job_with_nil_unique_args.rb index 00860bb4a..dede831c2 100644 --- a/spec/support/workers/unique_job_with_nil_unique_args.rb +++ b/spec/support/workers/unique_job_with_nil_unique_args.rb @@ -5,10 +5,10 @@ class UniqueJobWithNilUniqueArgs include Sidekiq::Worker sidekiq_options backtrace: true, - lock: :until_executed, - queue: :customqueue, - retry: true, - lock_args_method: :unique_args + lock: :until_executed, + queue: :customqueue, + retry: true, + lock_args_method: :unique_args def perform(args) [args] diff --git a/spec/support/workers/unique_job_with_no_unique_args_method.rb b/spec/support/workers/unique_job_with_no_unique_args_method.rb index bcf0be484..7153f568e 100644 --- a/spec/support/workers/unique_job_with_no_unique_args_method.rb +++ b/spec/support/workers/unique_job_with_no_unique_args_method.rb @@ -5,10 +5,10 @@ class UniqueJobWithNoUniqueArgsMethod include Sidekiq::Worker sidekiq_options backtrace: true, - lock: :until_executed, - queue: :customqueue, - retry: true, - lock_args_method: :filtered_args + lock: :until_executed, + queue: :customqueue, + retry: true, + lock_args_method: :filtered_args def perform(one, two) [one, two] diff --git a/spec/support/workers/unique_job_without_unique_args_parameter.rb b/spec/support/workers/unique_job_without_unique_args_parameter.rb index 74bba2d08..ce1ea3d4c 100644 --- a/spec/support/workers/unique_job_without_unique_args_parameter.rb +++ b/spec/support/workers/unique_job_without_unique_args_parameter.rb @@ -5,10 +5,10 @@ class UniqueJobWithoutUniqueArgsParameter include Sidekiq::Worker sidekiq_options backtrace: true, - lock: :until_executed, - queue: :customqueue, - retry: true, - lock_args_method: :unique_args + lock: :until_executed, + queue: :customqueue, + retry: true, + lock_args_method: :unique_args def perform(optional = true) # rubocop:disable Style/OptionalBooleanParameter optional diff --git a/spec/support/workers/until_and_while_executing_job.rb b/spec/support/workers/until_and_while_executing_job.rb index ed4791680..a50a87cbd 100644 --- a/spec/support/workers/until_and_while_executing_job.rb +++ b/spec/support/workers/until_and_while_executing_job.rb @@ -6,9 +6,9 @@ class UntilAndWhileExecutingJob include Sidekiq::Worker sidekiq_options lock: :until_and_while_executing, - lock_ttl: nil, - lock_timeout: 0, - queue: :working + lock_ttl: nil, + lock_timeout: 0, + queue: :working def perform(sleepy_time) sleep(sleepy_time) diff --git a/spec/support/workers/until_and_while_executing_log_raise_job.rb b/spec/support/workers/until_and_while_executing_log_raise_job.rb index 787816575..ee3f92b62 100644 --- a/spec/support/workers/until_and_while_executing_log_raise_job.rb +++ b/spec/support/workers/until_and_while_executing_log_raise_job.rb @@ -6,12 +6,12 @@ class UntilAndWhileExecutingLogRaiseJob include Sidekiq::Worker sidekiq_options lock: :until_and_while_executing, - queue: :working, - # lock_timeout: 0.5, - on_conflict: { - client: :log, - server: :raise, - } + queue: :working, + # lock_timeout: 0.5, + on_conflict: { + client: :log, + server: :raise, + } def perform(key) # Slow processing diff --git a/spec/support/workers/until_and_while_executing_reject_job.rb b/spec/support/workers/until_and_while_executing_reject_job.rb index 4e9c21332..74ee56a7c 100644 --- a/spec/support/workers/until_and_while_executing_reject_job.rb +++ b/spec/support/workers/until_and_while_executing_reject_job.rb @@ -6,11 +6,11 @@ class UntilAndWhileExecutingRejectJob include Sidekiq::Worker sidekiq_options lock: :until_and_while_executing, - queue: :working, - on_conflict: { - client: :reject, - server: :reject, - } + queue: :working, + on_conflict: { + client: :reject, + server: :reject, + } def self.lock_args(args) [args[0]] diff --git a/spec/support/workers/until_and_while_executing_replace_job.rb b/spec/support/workers/until_and_while_executing_replace_job.rb index c4d84c891..1286dad34 100644 --- a/spec/support/workers/until_and_while_executing_replace_job.rb +++ b/spec/support/workers/until_and_while_executing_replace_job.rb @@ -6,11 +6,11 @@ class UntilAndWhileExecutingReplaceJob include Sidekiq::Worker sidekiq_options lock: :until_and_while_executing, - queue: :working, - on_conflict: { - client: :replace, - server: :reschedule, - } + queue: :working, + on_conflict: { + client: :replace, + server: :reschedule, + } def self.lock_args(args) [args[0]] diff --git a/spec/support/workers/until_executed_2_job.rb b/spec/support/workers/until_executed_2_job.rb index 289bc5484..02152c1ed 100644 --- a/spec/support/workers/until_executed_2_job.rb +++ b/spec/support/workers/until_executed_2_job.rb @@ -9,10 +9,10 @@ class UntilExecuted2Job include Sidekiq::Worker sidekiq_options backtrace: 10, - lock: :until_executed, - lock_timeout: 0, - queue: :working, - retry: 1 + lock: :until_executed, + lock_timeout: 0, + queue: :working, + retry: 1 def perform(one, two) [one, two] diff --git a/spec/support/workers/until_executed_job.rb b/spec/support/workers/until_executed_job.rb index b791bbdc2..ac0876bc9 100644 --- a/spec/support/workers/until_executed_job.rb +++ b/spec/support/workers/until_executed_job.rb @@ -9,11 +9,11 @@ class UntilExecutedJob include Sidekiq::Worker sidekiq_options backtrace: 10, - lock: :until_executed, - lock_ttl: 5_000, - lock_timeout: 0, - queue: :working, - retry: 1 + lock: :until_executed, + lock_ttl: 5_000, + lock_timeout: 0, + queue: :working, + retry: 1 def perform(one, two = nil) [one, two] diff --git a/spec/support/workers/while_executing_job.rb b/spec/support/workers/while_executing_job.rb index 896527b13..385d849a0 100644 --- a/spec/support/workers/while_executing_job.rb +++ b/spec/support/workers/while_executing_job.rb @@ -5,9 +5,9 @@ class WhileExecutingJob include Sidekiq::Worker sidekiq_options backtrace: 10, - lock: :while_executing, - queue: :working, - retry: 1 + lock: :while_executing, + queue: :working, + retry: 1 def perform(args) [args] diff --git a/spec/support/workers/while_executing_reject_job.rb b/spec/support/workers/while_executing_reject_job.rb index 252f94dda..fc0578d8d 100644 --- a/spec/support/workers/while_executing_reject_job.rb +++ b/spec/support/workers/while_executing_reject_job.rb @@ -5,7 +5,7 @@ class WhileExecutingRejectJob include Sidekiq::Worker sidekiq_options lock: :while_executing_reject, - queue: :rejecting + queue: :rejecting def perform(_args) sleep 5 diff --git a/spec/support/workers/while_executing_reschedule_job.rb b/spec/support/workers/while_executing_reschedule_job.rb index b21e30219..18f52a30a 100644 --- a/spec/support/workers/while_executing_reschedule_job.rb +++ b/spec/support/workers/while_executing_reschedule_job.rb @@ -5,10 +5,10 @@ class WhileExecutingRescheduleJob include Sidekiq::Worker sidekiq_options backtrace: 10, - lock: :while_executing, - queue: :working, - on_conflict: :reschedule, - retry: 1 + lock: :while_executing, + queue: :working, + on_conflict: :reschedule, + retry: 1 def perform(args) [args] diff --git a/spec/workers/until_and_while_executing_reject_job_spec.rb b/spec/workers/until_and_while_executing_reject_job_spec.rb index 3f9f2b1cc..29529dfe7 100644 --- a/spec/workers/until_and_while_executing_reject_job_spec.rb +++ b/spec/workers/until_and_while_executing_reject_job_spec.rb @@ -4,10 +4,10 @@ it_behaves_like "sidekiq with options" do let(:options) do { + "lock" => :until_and_while_executing, + "on_conflict" => { "client" => :reject, "server" => :reject }, "queue" => :working, "retry" => true, - "lock" => :until_and_while_executing, - "on_conflict" => { client: :reject, server: :reject }, } end end diff --git a/spec/workers/until_and_while_executing_replace_job_spec.rb b/spec/workers/until_and_while_executing_replace_job_spec.rb index 13d889bc6..095521df2 100644 --- a/spec/workers/until_and_while_executing_replace_job_spec.rb +++ b/spec/workers/until_and_while_executing_replace_job_spec.rb @@ -7,7 +7,7 @@ "queue" => :working, "retry" => true, "lock" => :until_and_while_executing, - "on_conflict" => { client: :replace, server: :reschedule }, + "on_conflict" => { "client" => :replace, "server" => :reschedule }, } end end