Class: Timberline::Config

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initializeConfig

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

#databaseInteger

part of the redis configuration - index of the redis database to use

Returns:

  • (Integer)

    the current value of database



29
30
31
# File 'lib/timberline/config.rb', line 29

def database
  @database
end

#hostString

part of the redis configuration - the hostname of the redis server

Returns:

  • (String)

    the current value of host



29
30
31
# File 'lib/timberline/config.rb', line 29

def host
  @host
end

#log_job_result_statsBoolean

created in response to max memory limit on redis queues in aws

Returns:

  • (Boolean)

    configuration setting for logging each job success or error in redis



57
58
59
# File 'lib/timberline/config.rb', line 57

def log_job_result_stats
  @log_job_result_stats
end

#loggerLogger

part of the redis configuration - the logger to use for the redis connection

Returns:

  • (Logger)

    the current value of logger



29
30
31
# File 'lib/timberline/config.rb', line 29

def logger
  @logger
end

#max_retriesInteger

Returns the configured maximum number of retries, with a default of 5.

Returns:

  • (Integer)

    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

#namespaceString

Returns the configured redis namespace, with a default of ‘timberline’.

Returns:

  • (String)

    the configured redis namespace, with a default of ‘timberline’



29
30
31
# File 'lib/timberline/config.rb', line 29

def namespace
  @namespace
end

#passwordString

part of the redis configuration - the password for the redis server

Returns:

  • (String)

    the current value of password



29
30
31
# File 'lib/timberline/config.rb', line 29

def password
  @password
end

#portInteger

part of the redis configuration - the port of the redis server

Returns:

  • (Integer)

    the current value of port



29
30
31
# File 'lib/timberline/config.rb', line 29

def port
  @port
end

#sentinels{host: "x", port: 1}

Returns list of sentinel server.

Returns:

  • ({host: "x", port: 1})

    list of sentinel server



29
30
31
# File 'lib/timberline/config.rb', line 29

def sentinels
  @sentinels
end

#stat_timeoutInteger

Returns the configured lifetime of stats (in minutes), with a default of 60.

Returns:

  • (Integer)

    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

#timeoutInteger

part of the redis configuration - the timeout for the redis server

Returns:

  • (Integer)

    the current value of timeout



29
30
31
# File 'lib/timberline/config.rb', line 29

def timeout
  @timeout
end

Instance Method Details

#redis_configHash

Returns a Redis-ready hash for use in instantiating a new redis object.

Returns:

  • (Hash)

    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