Class: Resque::UniqueByArity::GlobalConfiguration

Inherits:
Configuration
  • Object
show all
Includes:
Singleton
Defined in:
lib/resque/unique_by_arity/global_configuration.rb

Overview

This class is for configurations that are app-wide, *not per job class. For this reason it is a Singleton. Will be used as the default settings for the per-job configs.

Constant Summary collapse

DEFAULT_LOG_LEVEL =
:debug
DEFAULT_LOCK_TIMEOUT =

For resque-unique_at_runtime

60 * 60 * 24 * 5
DEFAULT_REQUEUE_INTERVAL =
1
DEFAULT_AT_RUNTIME_KEY_BASE =
"r-uar".freeze
DEFAULT_LOCK_AFTER_EXECUTION_PERIOD =

For resque-unique_in_queue

0
DEFAULT_TTL =
-1
DEFAULT_IN_QUEUE_KEY_BASE =
"r-uiq".freeze

Constants inherited from Configuration

Configuration::SKIPPED_ARITY_VALIDATION_LEVELS, Configuration::VALID_ARITY_VALIDATION_LEVELS

Instance Attribute Summary

Attributes inherited from Configuration

#arity_for_uniqueness, #arity_for_uniqueness_across_queues, #arity_for_uniqueness_at_runtime, #arity_for_uniqueness_in_queue, #arity_validation, #base_klass_name, #debug_mode, #lock_after_execution_period, #log_level, #logger, #runtime_lock_timeout, #runtime_requeue_interval, #ttl, #unique_across_queues, #unique_at_runtime, #unique_at_runtime_key_base, #unique_in_queue, #unique_in_queue_key_base

Instance Method Summary collapse

Methods inherited from Configuration

#log, #skip_arity_validation?, #to_hash, #validate, #validate_arity

Constructor Details

#initializeGlobalConfiguration

Returns a new instance of GlobalConfiguration.



22
23
24
# File 'lib/resque/unique_by_arity/global_configuration.rb', line 22

def initialize
  reset
end

Instance Method Details

#defcon(sym) ⇒ Object



26
27
28
# File 'lib/resque/unique_by_arity/global_configuration.rb', line 26

def defcon(sym)
  send(sym)
end

#resetObject



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/resque/unique_by_arity/global_configuration.rb', line 30

def reset
  debug_mode_from_env
  @logger = nil
  @log_level = DEFAULT_LOG_LEVEL
  @arity_for_uniqueness = nil
  @arity_for_uniqueness_at_runtime = nil
  @arity_for_uniqueness_in_queue = nil
  @arity_for_uniqueness_across_queues = nil
  @arity_validation = nil
  @lock_after_execution_period = DEFAULT_LOCK_AFTER_EXECUTION_PERIOD
  @runtime_lock_timeout = DEFAULT_LOCK_TIMEOUT
  @runtime_requeue_interval = DEFAULT_REQUEUE_INTERVAL
  @unique_at_runtime_key_base = DEFAULT_AT_RUNTIME_KEY_BASE
  @unique_in_queue_key_base = DEFAULT_IN_QUEUE_KEY_BASE
  @unique_at_runtime = false
  @unique_in_queue = false
  @unique_across_queues = false
  @ttl = DEFAULT_TTL
  if @debug_mode
    # Make sure there is a logger when in debug_mode
    @logger ||= Logger.new(STDOUT)
  end
end