Class: Resque::UniqueInQueue::Configuration
- Inherits:
-
Object
- Object
- Resque::UniqueInQueue::Configuration
- Defined in:
- lib/resque/unique_in_queue/configuration.rb
Constant Summary collapse
- DEFAULT_IN_QUEUE_KEY_BASE =
'r-uiq'.freeze
- DEFAULT_LOCK_AFTER_EXECUTION_PERIOD =
0- DEFAULT_TTL =
-1
Class Attribute Summary collapse
-
.unique_in_queue_key_base ⇒ Object
Returns the value of attribute unique_in_queue_key_base.
Instance Attribute Summary collapse
-
#debug_mode ⇒ Object
Returns the value of attribute debug_mode.
-
#lock_after_execution_period ⇒ Object
Returns the value of attribute lock_after_execution_period.
-
#log_level ⇒ Object
Returns the value of attribute log_level.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#ttl ⇒ Object
Returns the value of attribute ttl.
Instance Method Summary collapse
-
#initialize(**options) ⇒ Configuration
constructor
A new instance of Configuration.
- #log(msg) ⇒ Object
- #to_hash ⇒ Object
- #unique_in_queue_key_base ⇒ Object
- #unique_log_level ⇒ Object
- #unique_logger ⇒ Object
Constructor Details
#initialize(**options) ⇒ Configuration
Returns a new instance of Configuration.
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/resque/unique_in_queue/configuration.rb', line 21 def initialize(**) @logger = .key?(:logger) ? [:logger] : Logger.new(STDOUT) @log_level = .key?(:log_level) ? [:log_level] : :debug @unique_in_queue_key_base = .key?(:unique_in_queue_key_base) ? [:unique_in_queue_key_base] : nil # Can be set per each job: @lock_after_execution_period = .key?(:lock_after_execution_period) ? [:lock_after_execution_period] : DEFAULT_LOCK_AFTER_EXECUTION_PERIOD @ttl = .key?(:ttl) ? [:ttl] : DEFAULT_TTL env_debug = ENV['RESQUE_DEBUG'] @debug_mode = .key?(:debug_mode) ? [:debug_mode] : env_debug == 'true' || (env_debug.is_a?(String) && env_debug.match?(/in_queue/)) end |
Class Attribute Details
.unique_in_queue_key_base ⇒ Object
Returns the value of attribute unique_in_queue_key_base.
16 17 18 |
# File 'lib/resque/unique_in_queue/configuration.rb', line 16 def unique_in_queue_key_base @unique_in_queue_key_base end |
Instance Attribute Details
#debug_mode ⇒ Object
Returns the value of attribute debug_mode.
9 10 11 |
# File 'lib/resque/unique_in_queue/configuration.rb', line 9 def debug_mode @debug_mode end |
#lock_after_execution_period ⇒ Object
Returns the value of attribute lock_after_execution_period.
9 10 11 |
# File 'lib/resque/unique_in_queue/configuration.rb', line 9 def lock_after_execution_period @lock_after_execution_period end |
#log_level ⇒ Object
Returns the value of attribute log_level.
9 10 11 |
# File 'lib/resque/unique_in_queue/configuration.rb', line 9 def log_level @log_level end |
#logger ⇒ Object
Returns the value of attribute logger.
9 10 11 |
# File 'lib/resque/unique_in_queue/configuration.rb', line 9 def logger @logger end |
#ttl ⇒ Object
Returns the value of attribute ttl.
9 10 11 |
# File 'lib/resque/unique_in_queue/configuration.rb', line 9 def ttl @ttl end |
Instance Method Details
#log(msg) ⇒ Object
41 42 43 |
# File 'lib/resque/unique_in_queue/configuration.rb', line 41 def log(msg) Resque::UniqueInQueue.in_queue_unique_log(msg, self) end |
#to_hash ⇒ Object
49 50 51 52 53 54 |
# File 'lib/resque/unique_in_queue/configuration.rb', line 49 def to_hash { logger: logger, log_level: log_level } end |
#unique_in_queue_key_base ⇒ Object
45 46 47 |
# File 'lib/resque/unique_in_queue/configuration.rb', line 45 def unique_in_queue_key_base @unique_in_queue_key_base || self.class.unique_in_queue_key_base end |
#unique_log_level ⇒ Object
37 38 39 |
# File 'lib/resque/unique_in_queue/configuration.rb', line 37 def unique_log_level log_level end |
#unique_logger ⇒ Object
33 34 35 |
# File 'lib/resque/unique_in_queue/configuration.rb', line 33 def unique_logger logger end |