Class: Resque::UniqueAtRuntime::Configuration
- Inherits:
-
Object
- Object
- Resque::UniqueAtRuntime::Configuration
- Defined in:
- lib/resque/unique_at_runtime/configuration.rb
Constant Summary collapse
- DEFAULT_AT_RUNTIME_KEY_BASE =
'r-uae'- DEFAULT_LOCK_TIMEOUT =
60 * 60 * 24 * 5
- DEFAULT_REQUEUE_INTERVAL =
1
Class Attribute Summary collapse
-
.unique_at_runtime_key_base ⇒ Object
Returns the value of attribute unique_at_runtime_key_base.
Instance Attribute Summary collapse
-
#debug_mode ⇒ Object
Returns the value of attribute debug_mode.
-
#lock_timeout ⇒ Object
Returns the value of attribute lock_timeout.
-
#log_level ⇒ Object
Returns the value of attribute log_level.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#requeue_interval ⇒ Object
Returns the value of attribute requeue_interval.
Instance Method Summary collapse
-
#initialize(**options) ⇒ Configuration
constructor
A new instance of Configuration.
- #log(msg) ⇒ Object
- #to_hash ⇒ Object
- #unique_at_runtime_key_base ⇒ Object
- #unique_log_level ⇒ Object
- #unique_logger ⇒ Object
Constructor Details
#initialize(**options) ⇒ Configuration
Returns a new instance of Configuration.
23 24 25 26 27 28 29 30 31 |
# File 'lib/resque/unique_at_runtime/configuration.rb', line 23 def initialize(**) @logger = .key?(:logger) ? [:logger] : Logger.new(STDOUT) @log_level = .key?(:log_level) ? [:log_level] : :debug @unique_at_runtime_key_base = .key?(:unique_at_runtime_key_base) ? [:unique_at_runtime_key_base] : nil @lock_timeout = .key?(:lock_timeout) ? [:lock_timeout] : DEFAULT_LOCK_TIMEOUT @requeue_interval = .key?(:requeue_interval) ? [:requeue_interval] : DEFAULT_REQUEUE_INTERVAL env_debug = ENV['RESQUE_DEBUG'] @debug_mode = !!(.key?(:debug_mode) ? [:debug_mode] : env_debug == 'true' || (env_debug.is_a?(String) && env_debug.match?(/runtime/))) end |
Class Attribute Details
.unique_at_runtime_key_base ⇒ Object
Returns the value of attribute unique_at_runtime_key_base.
18 19 20 |
# File 'lib/resque/unique_at_runtime/configuration.rb', line 18 def unique_at_runtime_key_base @unique_at_runtime_key_base end |
Instance Attribute Details
#debug_mode ⇒ Object
Returns the value of attribute debug_mode.
11 12 13 |
# File 'lib/resque/unique_at_runtime/configuration.rb', line 11 def debug_mode @debug_mode end |
#lock_timeout ⇒ Object
Returns the value of attribute lock_timeout.
11 12 13 |
# File 'lib/resque/unique_at_runtime/configuration.rb', line 11 def lock_timeout @lock_timeout end |
#log_level ⇒ Object
Returns the value of attribute log_level.
11 12 13 |
# File 'lib/resque/unique_at_runtime/configuration.rb', line 11 def log_level @log_level end |
#logger ⇒ Object
Returns the value of attribute logger.
11 12 13 |
# File 'lib/resque/unique_at_runtime/configuration.rb', line 11 def logger @logger end |
#requeue_interval ⇒ Object
Returns the value of attribute requeue_interval.
11 12 13 |
# File 'lib/resque/unique_at_runtime/configuration.rb', line 11 def requeue_interval @requeue_interval end |
Instance Method Details
#log(msg) ⇒ Object
41 42 43 |
# File 'lib/resque/unique_at_runtime/configuration.rb', line 41 def log(msg) Resque::UniqueAtRuntime.runtime_unique_log(msg, self) end |
#to_hash ⇒ Object
49 50 51 52 53 54 55 56 57 58 |
# File 'lib/resque/unique_at_runtime/configuration.rb', line 49 def to_hash { logger: logger, log_level: log_level, debug_mode: debug_mode, unique_at_runtime_key_base: unique_at_runtime_key_base, lock_timeout: lock_timeout, requeue_interval: requeue_interval } end |
#unique_at_runtime_key_base ⇒ Object
45 46 47 |
# File 'lib/resque/unique_at_runtime/configuration.rb', line 45 def unique_at_runtime_key_base @unique_at_runtime_key_base || self.class.unique_at_runtime_key_base end |
#unique_log_level ⇒ Object
37 38 39 |
# File 'lib/resque/unique_at_runtime/configuration.rb', line 37 def unique_log_level log_level end |
#unique_logger ⇒ Object
33 34 35 |
# File 'lib/resque/unique_at_runtime/configuration.rb', line 33 def unique_logger logger end |