Sha256: b7e89833f00911c2e318adac2b9458759e76d8b3a87bb8751b8bbb577facbbd5

Contents?: true

Size: 1.22 KB

Versions: 24

Compression:

Stored size: 1.22 KB

Contents

# frozen_string_literal: true

require_relative "on_conflict/strategy"
require_relative "on_conflict/null_strategy"
require_relative "on_conflict/log"
require_relative "on_conflict/raise"
require_relative "on_conflict/reject"
require_relative "on_conflict/replace"
require_relative "on_conflict/reschedule"

module SidekiqUniqueJobs
  #
  # Provides lock conflict resolutions
  #
  # @author Mikael Henriksson <mikael@zoolutions.se>
  #
  module OnConflict
    # A convenience method for using the configured strategies
    def self.strategies
      SidekiqUniqueJobs.strategies
    end

    #
    # Find a strategy to use for conflicting locks
    #
    # @param [Symbol] strategy the key for the strategy
    #
    # @return [OnConflict::Strategy] when found
    # @return [OnConflict::NullStrategy] when no other could be found
    #
    def self.find_strategy(strategy)
      return OnConflict::NullStrategy unless strategy

      strategies.fetch(strategy.to_sym) do
        SidekiqUniqueJobs.logger.warn(
          "No matching implementation for strategy: #{strategy}, returning OnConflict::NullStrategy." \
          " Available strategies are (#{strategies.inspect})",
        )

        OnConflict::NullStrategy
      end
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
sidekiq-unique-jobs-7.0.0.beta25 lib/sidekiq_unique_jobs/on_conflict.rb
sidekiq-unique-jobs-7.0.0.beta24 lib/sidekiq_unique_jobs/on_conflict.rb
sidekiq-unique-jobs-7.0.0.beta23 lib/sidekiq_unique_jobs/on_conflict.rb
sidekiq-unique-jobs-7.0.0.beta22 lib/sidekiq_unique_jobs/on_conflict.rb
sidekiq-unique-jobs-7.0.0.beta21 lib/sidekiq_unique_jobs/on_conflict.rb
sidekiq-unique-jobs-7.0.0.beta20 lib/sidekiq_unique_jobs/on_conflict.rb
sidekiq-unique-jobs-7.0.0.beta19 lib/sidekiq_unique_jobs/on_conflict.rb
sidekiq-unique-jobs-7.0.0.beta18 lib/sidekiq_unique_jobs/on_conflict.rb
sidekiq-unique-jobs-7.0.0.beta17 lib/sidekiq_unique_jobs/on_conflict.rb
sidekiq-unique-jobs-7.0.0.beta16 lib/sidekiq_unique_jobs/on_conflict.rb
sidekiq-unique-jobs-7.0.0.beta15 lib/sidekiq_unique_jobs/on_conflict.rb
sidekiq-unique-jobs-7.0.0.beta14 lib/sidekiq_unique_jobs/on_conflict.rb
sidekiq-unique-jobs-7.0.0.beta13 lib/sidekiq_unique_jobs/on_conflict.rb
sidekiq-unique-jobs-7.0.0.beta12 lib/sidekiq_unique_jobs/on_conflict.rb
sidekiq-unique-jobs-7.0.0.beta11 lib/sidekiq_unique_jobs/on_conflict.rb
sidekiq-unique-jobs-7.0.0.beta10 lib/sidekiq_unique_jobs/on_conflict.rb
sidekiq-unique-jobs-7.0.0.beta9 lib/sidekiq_unique_jobs/on_conflict.rb
sidekiq-unique-jobs-7.0.0.beta8 lib/sidekiq_unique_jobs/on_conflict.rb
sidekiq-unique-jobs-7.0.0.beta7 lib/sidekiq_unique_jobs/on_conflict.rb
sidekiq-unique-jobs-7.0.0.beta6 lib/sidekiq_unique_jobs/on_conflict.rb