Class: PushyDaemon::Proxy

Inherits:
Endpoint show all
Defined in:
lib/pushyd/proxy.rb

Overview

class ProxyConnexionContext < StandardError; end

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeProxy

Returns a new instance of Proxy.



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
# File 'lib/pushyd/proxy.rb', line 14

def initialize
  # Init
  super
  @exchanges = {}

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

  # Start connexion to RabbitMQ and create channel
  conn = connect Conf.bus
  @channel = conn.create_channel
  info "connected on a channel"

  # Check config
  config_rules = Conf[:rules]
  unless (config_rules.is_a? Enumerable) && !config_rules.empty?
    error "prepare: empty [rules] section"
  end
  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
    #abort "prepare: OK"
  end

  # Send config table to logs
  info "dumping configuration\n#{@table.to_s}"

rescue Bunny::TCPConnectionFailedForAllHosts => e
  error "ERROR: cannot connect to RabbitMQ hosts (#{e.inspect})"
end

Instance Attribute Details

#tableObject

Returns the value of attribute table.



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

def table
  @table
end