class SidekiqUniqueJobs::Lock::Validator


@author Mikael Henriksson <mikael@mhenrixon.com>
Validator base class to avoid some duplication

def self.validate(options)

Returns:
  • (LockConfig) - the lock configuration with errors if any

Parameters:
  • options (Hash) -- the sidekiq_options for the worker being validated
def self.validate(options)
  new(options).validate
end

def handle_deprecations

Returns:
  • (void) -
def handle_deprecations
  DEPRECATED_KEYS.each do |old, new|
    next unless @options.key?(old)
    lock_config.errors[old] = "is deprecated, use `#{new}: #{@options[old]}` instead."
  end
end

def initialize(options)

Parameters:
  • options (Hash) -- the sidekiq_options for the worker being validated
def initialize(options)
  @options     = options.transform_keys(&:to_sym)
  @lock_config = LockConfig.new(options)
  handle_deprecations
end

def validate

Returns:
  • (LockConfig) - the lock configuration with errors if any
def validate
  case lock_config.type
  when :while_executing
    validate_server
  when :until_executing
    validate_client
  else
    validate_client
    validate_server
  end
  lock_config
end

def validate_client


Validates the client configuration
def validate_client
  ClientValidator.validate(lock_config)
end

def validate_server


Validates the server configuration
def validate_server
  ServerValidator.validate(lock_config)
end