Class: Routemaster::Config

Inherits:
Object
  • Object
show all
Extended by:
Classmethods
Defined in:
lib/routemaster/config.rb

Defined Under Namespace

Modules: Classmethods

Instance Method Summary collapse

Methods included from Classmethods

method_missing, respond_to?

Instance Method Details

#cache_authObject



45
46
47
48
49
50
51
52
# File 'lib/routemaster/config.rb', line 45

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_expiryObject



41
42
43
# File 'lib/routemaster/config.rb', line 41

def cache_expiry
  Integer(ENV.fetch('ROUTEMASTER_CACHE_EXPIRY', 86_400 * 365))
end

#cache_redisObject



23
24
25
# File 'lib/routemaster/config.rb', line 23

def cache_redis
  RedisBroker.instance.get(ENV.fetch('ROUTEMASTER_CACHE_REDIS'))
end

#drain_redisObject



19
20
21
# File 'lib/routemaster/config.rb', line 19

def drain_redis
  RedisBroker.instance.get(ENV.fetch('ROUTEMASTER_DRAIN_REDIS'))
end

#drain_tokensObject



62
63
64
# File 'lib/routemaster/config.rb', line 62

def drain_tokens
  Set.new(ENV.fetch('ROUTEMASTER_DRAIN_TOKENS').split(','))
end

#hostsObject

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 }



31
32
33
34
35
36
37
38
39
# File 'lib/routemaster/config.rb', line 31

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

#queue_adapterObject



54
55
56
# File 'lib/routemaster/config.rb', line 54

def queue_adapter
  ENV.fetch('ROUTEMASTER_QUEUE_ADAPTER', 'resque').to_sym
end

#queue_nameObject



58
59
60
# File 'lib/routemaster/config.rb', line 58

def queue_name
  ENV.fetch('ROUTEMASTER_QUEUE_NAME', 'routemaster')
end

#url_expansionsObject



66
67
68
69
70
71
72
73
# File 'lib/routemaster/config.rb', line 66

def url_expansions
  Hashie::Rash.new.tap do |result|
    ENV.fetch('ROUTEMASTER_URL_EXPANSIONS', '').split(',').each do |entry|
      host, username, password = entry.split(':')
      result[Regexp.new(host)] = [username, password]
    end
  end
end