Class: ResqueToCloudwatch::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/resque_to_cloudwatch/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Config

Returns a new instance of Config.



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/resque_to_cloudwatch/config.rb', line 12

def initialize(path)
  $log.info "Loading configuration"
  raise "Config file #{path} not found or readable" unless File.exists?(path)
  @required_opts = %w{access_key_id secret_access_key project period region redis_host redis_port namespace}
  @hash = YAML.load_file(path)
  raise "Config file #{path} is empty" unless @hash
  validate_config
  @hash.each_pair do |opt,value|
    # Support old-style where region is not an array
    if opt == 'region' && value.is_a?(String)
      value = [value]
    end
    instance_variable_set("@#{opt}", value)
    $log.info "Config parameter: #{opt} is #{value}"
  end
  
  # Set up AWS credentials
  AWS.config(
    :access_key_id => @hash['access_key_id'],
    :secret_access_key => @hash['secret_access_key']
  )
end

Instance Attribute Details

#access_key_idObject (readonly)

Returns the value of attribute access_key_id.



7
8
9
# File 'lib/resque_to_cloudwatch/config.rb', line 7

def access_key_id
  @access_key_id
end

#enable_graphiteObject (readonly)

Returns the value of attribute enable_graphite.



9
10
11
# File 'lib/resque_to_cloudwatch/config.rb', line 9

def enable_graphite
  @enable_graphite
end

#graphite_hostObject (readonly)

Returns the value of attribute graphite_host.



9
10
11
# File 'lib/resque_to_cloudwatch/config.rb', line 9

def graphite_host
  @graphite_host
end

#graphite_portObject (readonly)

Returns the value of attribute graphite_port.



9
10
11
# File 'lib/resque_to_cloudwatch/config.rb', line 9

def graphite_port
  @graphite_port
end

#hostnameObject (readonly)

Returns the value of attribute hostname.



8
9
10
# File 'lib/resque_to_cloudwatch/config.rb', line 8

def hostname
  @hostname
end

#namespaceObject (readonly)

Returns the value of attribute namespace.



10
11
12
# File 'lib/resque_to_cloudwatch/config.rb', line 10

def namespace
  @namespace
end

#periodObject (readonly)

Returns the value of attribute period.



7
8
9
# File 'lib/resque_to_cloudwatch/config.rb', line 7

def period
  @period
end

#projectObject (readonly)

Returns the value of attribute project.



7
8
9
# File 'lib/resque_to_cloudwatch/config.rb', line 7

def project
  @project
end

#redis_hostObject (readonly)

Returns the value of attribute redis_host.



8
9
10
# File 'lib/resque_to_cloudwatch/config.rb', line 8

def redis_host
  @redis_host
end

#redis_portObject (readonly)

Returns the value of attribute redis_port.



8
9
10
# File 'lib/resque_to_cloudwatch/config.rb', line 8

def redis_port
  @redis_port
end

#regionObject (readonly)

Returns the value of attribute region.



7
8
9
# File 'lib/resque_to_cloudwatch/config.rb', line 7

def region
  @region
end

#secret_access_keyObject (readonly)

Returns the value of attribute secret_access_key.



7
8
9
# File 'lib/resque_to_cloudwatch/config.rb', line 7

def secret_access_key
  @secret_access_key
end