Class: PushyDaemon::Proxy

Inherits:
Endpoint show all
Includes:
NewRelic::Agent::Instrumentation::ControllerInstrumentation, Shared::HmacSignature
Defined in:
lib/pushyd/proxy.rb

Constant Summary

Constants included from Shared::LoggerHelper

Shared::LoggerHelper::CONFIG_PATH

Instance Attribute Summary collapse

Attributes inherited from Endpoint

#logger

Instance Method Summary collapse

Methods included from Shared::HmacSignature

#headers_md5, #headers_sign

Methods included from Shared::LoggerHelper

#logfile

Constructor Details

#initializeProxy

Returns a new instance of Proxy.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/pushyd/proxy.rb', line 11

def initialize
  # Init
  super
  @exchanges = {}

  # Init ASCII table
  @table = Terminal::Table.new
  @table.title = "Propagation rules"
  @table.headings = ["rule", "topic", "route", "relay", "created queue", "description"]
  @table.align_column(5, :right)

  # Start connexion to RabbitMQ and create channel
  @channel = connect_channel Conf.amqp
  log_info "channel connected"

  # Check config
  config_rules = Conf[:rules]
  if config_rules.nil? || !config_rules.is_a?(Hash)
    log_error "prepare: empty [rules] section"
  else
    log_info "found rules: #{config_rules.keys.join(', ')}"

    # Subsribe for each and every rule/route
    config_rules.each do |name, rule|
      rule[:name] = name
      channel_subscribe rule
    end
  end

  # Send config table to logs
  log_info "proxy initialized", @table.to_s.lines
end

Instance Attribute Details

#tableObject

Returns the value of attribute table.



9
10
11
# File 'lib/pushyd/proxy.rb', line 9

def table
  @table
end