Class: MemHealth::Configuration
- Inherits:
-
Object
- Object
- MemHealth::Configuration
- Defined in:
- lib/mem_health/configuration.rb
Instance Attribute Summary collapse
-
#enabled ⇒ Object
Returns the value of attribute enabled.
-
#max_stored_urls ⇒ Object
Returns the value of attribute max_stored_urls.
-
#memory_threshold_mb ⇒ Object
Returns the value of attribute memory_threshold_mb.
-
#ram_before_threshold_mb ⇒ Object
Returns the value of attribute ram_before_threshold_mb.
-
#redis_key_prefix ⇒ Object
Returns the value of attribute redis_key_prefix.
-
#redis_url ⇒ Object
Returns the value of attribute redis_url.
-
#skip_requests ⇒ Object
Returns the value of attribute skip_requests.
Instance Method Summary collapse
- #enabled? ⇒ Boolean
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #redis ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/mem_health/configuration.rb', line 13 def initialize @enabled = ENV.fetch("MEM_HEALTH_ENABLED", "false") == "true" @skip_requests = ENV.fetch("MEM_HEALTH_SKIP_REQUESTS", "10").to_i @memory_threshold_mb = ENV.fetch("MEM_HEALTH_MEMORY_THRESHOLD_MB", "1").to_i @ram_before_threshold_mb = ENV.fetch("MEM_HEALTH_RAM_BEFORE_THRESHOLD", "0").to_i @max_stored_urls = ENV.fetch("MEM_HEALTH_MAX_STORED_URLS", "20").to_i redis_env_key = ENV.fetch("MEM_HEALTH_REDIS_KEY", "REDIS_URL") @redis_url = ENV.fetch(redis_env_key, "redis://localhost:6379/0") @redis_key_prefix = "memhealth" end |
Instance Attribute Details
#enabled ⇒ Object
Returns the value of attribute enabled.
5 6 7 |
# File 'lib/mem_health/configuration.rb', line 5 def enabled @enabled end |
#max_stored_urls ⇒ Object
Returns the value of attribute max_stored_urls.
5 6 7 |
# File 'lib/mem_health/configuration.rb', line 5 def max_stored_urls @max_stored_urls end |
#memory_threshold_mb ⇒ Object
Returns the value of attribute memory_threshold_mb.
5 6 7 |
# File 'lib/mem_health/configuration.rb', line 5 def memory_threshold_mb @memory_threshold_mb end |
#ram_before_threshold_mb ⇒ Object
Returns the value of attribute ram_before_threshold_mb.
5 6 7 |
# File 'lib/mem_health/configuration.rb', line 5 def ram_before_threshold_mb @ram_before_threshold_mb end |
#redis_key_prefix ⇒ Object
Returns the value of attribute redis_key_prefix.
5 6 7 |
# File 'lib/mem_health/configuration.rb', line 5 def redis_key_prefix @redis_key_prefix end |
#redis_url ⇒ Object
Returns the value of attribute redis_url.
5 6 7 |
# File 'lib/mem_health/configuration.rb', line 5 def redis_url @redis_url end |
#skip_requests ⇒ Object
Returns the value of attribute skip_requests.
5 6 7 |
# File 'lib/mem_health/configuration.rb', line 5 def skip_requests @skip_requests end |
Instance Method Details
#enabled? ⇒ Boolean
24 25 26 |
# File 'lib/mem_health/configuration.rb', line 24 def enabled? @enabled end |
#redis ⇒ Object
28 29 30 |
# File 'lib/mem_health/configuration.rb', line 28 def redis @redis ||= Redis.new(url: redis_url) end |