class Routemaster::Config

Attributes

logger[W]

Public Instance Methods

cache_auth() click to toggle source
# File lib/routemaster/config.rb, line 56
def cache_auth
  Hashie::Rash.new.tap do |result|
    ENV.fetch('ROUTEMASTER_CACHE_AUTH', '').split(',').each do |entry|
      host, username, password = entry.split(':')
      result[Regexp.new(host)] = [username, password]
    end
  end
end
cache_expiry() click to toggle source
# File lib/routemaster/config.rb, line 49
def cache_expiry
  # Do not increase this default value. It's likely that cached data will include PII
  # and 90 days is the maximum permitted retention period at Deliveroo. A higher value
  # means we would need to worry about purging caches at the end of the period.
  Integer(ENV.fetch('ROUTEMASTER_CACHE_EXPIRY', 86_400 * 90))
end
cache_redis() click to toggle source
# File lib/routemaster/config.rb, line 31
def cache_redis
  RedisBroker.instance.get(:cache_redis, urls: ENV.fetch('ROUTEMASTER_CACHE_REDIS', '').split(','))
end
drain_redis() click to toggle source
# File lib/routemaster/config.rb, line 27
def drain_redis
  RedisBroker.instance.get(:drain_redis, urls: ENV.fetch('ROUTEMASTER_DRAIN_REDIS', '').split(','))
end
drain_tokens() click to toggle source
# File lib/routemaster/config.rb, line 73
def drain_tokens
  Set.new(ENV.fetch('ROUTEMASTER_DRAIN_TOKENS').split(','))
end
hosts() click to toggle source

Given an ENV format of service:service_root_url,other_service:other_service_root_url Generate a hash of { service => service_root_url, other_service => other_service_root_url }

# File lib/routemaster/config.rb, line 39
def hosts
  @hosts ||= begin
               hosts = ENV['ROUTEMASTER_DRAIN_HOSTS'].split(',')
               hosts.inject({}) do |res, host|
                 key, val = host.split(':')
                 res.merge(key => val)
               end
             end
end
logger() click to toggle source
# File lib/routemaster/config.rb, line 23
def logger
  @logger ||= NullLogger.new
end
queue_adapter() click to toggle source
# File lib/routemaster/config.rb, line 65
def queue_adapter
  ENV.fetch('ROUTEMASTER_QUEUE_ADAPTER', 'resque').to_sym
end
queue_name() click to toggle source
# File lib/routemaster/config.rb, line 69
def queue_name
  ENV.fetch('ROUTEMASTER_QUEUE_NAME', 'routemaster')
end