Class: PushyDaemon::Proxy

Inherits:
BmcDaemonLib::MqEndpoint
  • Object
show all
Defined in:
lib/pushyd/proxy.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeProxy

Returns a new instance of Proxy.



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
43
44
45
46
47
48
49
50
# File 'lib/pushyd/proxy.rb', line 13

def initialize
  # Init
  @shouters = []
  @consumers = []

  # 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)

  # Prepare logger
  @logger = BmcDaemonLib::LoggerPool.instance.get

  # Start connexion to RabbitMQ
  @conn = connect_to BmcDaemonLib::Conf[:broker]
  log_info "Proxy connected"

  # Check config and subscribe rules
  create_consumers

  # Create a new shouter, and start its loop
  create_shouter

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

  rescue BmcDaemonLib::MqConsumerException, EndpointConnectionError, ShouterInterrupted, Errno::EACCES => e
    log_error "Proxy: #{e.message}"
    abort "EXITING #{e.class}: #{e.message}"

  rescue StandardError => e
    log_error "Proxy: #{e.message}", e.backtrace
    abort "EXITING #{e.class}: #{e.message} \n #{e.backtrace.to_yaml}"

    raise MqConsumerException, e.message

end

Instance Attribute Details

#tableObject

Class options



11
12
13
# File 'lib/pushyd/proxy.rb', line 11

def table
  @table
end