Class: Timberline::Config
- Inherits:
-
Object
- Object
- Timberline::Config
- Defined in:
- lib/timberline/config.rb
Overview
Object that manages Timberline configuration. Responsible for Redis configs as well as Timberline-specific configuration values, like how many times an item should be retried in a queue.
Instance Attribute Summary collapse
-
#database ⇒ Integer
part of the redis configuration - index of the redis database to use.
-
#host ⇒ String
part of the redis configuration - the hostname of the redis server.
-
#log_job_result_stats ⇒ Boolean
created in response to max memory limit on redis queues in aws.
-
#logger ⇒ Logger
part of the redis configuration - the logger to use for the redis connection.
-
#max_retries ⇒ Integer
The configured maximum number of retries, with a default of 5.
-
#namespace ⇒ String
The configured redis namespace, with a default of ‘timberline’.
-
#password ⇒ String
part of the redis configuration - the password for the redis server.
-
#port ⇒ Integer
part of the redis configuration - the port of the redis server.
-
#sentinels ⇒ {host: "x", port: 1}
List of sentinel server.
-
#stat_timeout ⇒ Integer
The configured lifetime of stats (in minutes), with a default of 60.
-
#timeout ⇒ Integer
part of the redis configuration - the timeout for the redis server.
Instance Method Summary collapse
-
#initialize ⇒ Config
constructor
Attemps to load configuration from TIMBERLINE_YAML, if it exists.
-
#redis_config ⇒ Hash
A Redis-ready hash for use in instantiating a new redis object.
Constructor Details
#initialize ⇒ Config
Attemps to load configuration from TIMBERLINE_YAML, if it exists. Otherwise creates a default Config object.
35 36 37 38 |
# File 'lib/timberline/config.rb', line 35 def initialize configure_via_yaml configure_via_env end |
Instance Attribute Details
#database ⇒ Integer
part of the redis configuration - index of the redis database to use
29 30 31 |
# File 'lib/timberline/config.rb', line 29 def database @database end |
#host ⇒ String
part of the redis configuration - the hostname of the redis server
29 30 31 |
# File 'lib/timberline/config.rb', line 29 def host @host end |
#log_job_result_stats ⇒ Boolean
created in response to max memory limit on redis queues in aws
57 58 59 |
# File 'lib/timberline/config.rb', line 57 def log_job_result_stats @log_job_result_stats end |
#logger ⇒ Logger
part of the redis configuration - the logger to use for the redis connection
29 30 31 |
# File 'lib/timberline/config.rb', line 29 def logger @logger end |
#max_retries ⇒ Integer
Returns the configured maximum number of retries, with a default of 5.
29 30 31 |
# File 'lib/timberline/config.rb', line 29 def max_retries @max_retries end |
#namespace ⇒ String
Returns the configured redis namespace, with a default of ‘timberline’.
29 30 31 |
# File 'lib/timberline/config.rb', line 29 def namespace @namespace end |
#password ⇒ String
part of the redis configuration - the password for the redis server
29 30 31 |
# File 'lib/timberline/config.rb', line 29 def password @password end |
#port ⇒ Integer
part of the redis configuration - the port of the redis server
29 30 31 |
# File 'lib/timberline/config.rb', line 29 def port @port end |
#sentinels ⇒ {host: "x", port: 1}
Returns list of sentinel server.
29 30 31 |
# File 'lib/timberline/config.rb', line 29 def sentinels @sentinels end |
#stat_timeout ⇒ Integer
Returns the configured lifetime of stats (in minutes), with a default of 60.
29 30 31 |
# File 'lib/timberline/config.rb', line 29 def stat_timeout @stat_timeout end |
#timeout ⇒ Integer
part of the redis configuration - the timeout for the redis server
29 30 31 |
# File 'lib/timberline/config.rb', line 29 def timeout @timeout end |
Instance Method Details
#redis_config ⇒ Hash
Returns a Redis-ready hash for use in instantiating a new redis object.
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/timberline/config.rb', line 67 def redis_config config = {} { db: database, host: host, port: port, timeout: timeout, password: password, logger: logger, sentinels: sentinels.empty? ? nil : sentinels }.each do |name, value| config[name] = value unless value.nil? end config end |