Module: Batsir::AMQP

Included in:
Batsir::Acceptors::AMQPAcceptor, Notifiers::AMQPNotifier
Defined in:
lib/batsir/amqp.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#durableObject

Returns the value of attribute durable.



8
9
10
# File 'lib/batsir/amqp.rb', line 8

def durable
  @durable
end

#exchangeObject

Returns the value of attribute exchange.



10
11
12
# File 'lib/batsir/amqp.rb', line 10

def exchange
  @exchange
end

#heartbeatObject

Returns the value of attribute heartbeat.



11
12
13
# File 'lib/batsir/amqp.rb', line 11

def heartbeat
  @heartbeat
end

#hostObject

Returns the value of attribute host.



4
5
6
# File 'lib/batsir/amqp.rb', line 4

def host
  @host
end

#passwordObject

Returns the value of attribute password.



7
8
9
# File 'lib/batsir/amqp.rb', line 7

def password
  @password
end

#portObject

Returns the value of attribute port.



5
6
7
# File 'lib/batsir/amqp.rb', line 5

def port
  @port
end

#queueObject

Returns the value of attribute queue.



3
4
5
# File 'lib/batsir/amqp.rb', line 3

def queue
  @queue
end

#usernameObject

Returns the value of attribute username.



6
7
8
# File 'lib/batsir/amqp.rb', line 6

def username
  @username
end

#vhostObject

Returns the value of attribute vhost.



9
10
11
# File 'lib/batsir/amqp.rb', line 9

def vhost
  @vhost
end

Instance Method Details

#bunny_optionsObject



13
14
15
16
17
18
19
20
21
22
# File 'lib/batsir/amqp.rb', line 13

def bunny_options
  {
    :host  => host,
    :port  => port,
    :user  => username,
    :pass  => password,
    :vhost => vhost,
    :heartbeat => heartbeat
  }
end

#bunny_poolObject



64
65
66
67
68
69
70
71
# File 'lib/batsir/amqp.rb', line 64

def bunny_pool
  @bunny_pool = Batsir::Registry.get(bunny_pool_key)
  if !@bunny_pool
    pool = ConnectionPool.new(:size => bunny_pool_size) { Bunny.new(bunny_options).start }
    @bunny_pool = Batsir::Registry.register(bunny_pool_key, pool)
  end
  @bunny_pool
end

#bunny_pool_keyObject



60
61
62
# File 'lib/batsir/amqp.rb', line 60

def bunny_pool_key
  "bunny_pool_for_#{host}_#{port}_#{vhost}"
end

#bunny_pool_sizeObject



52
53
54
# File 'lib/batsir/amqp.rb', line 52

def bunny_pool_size
  @bunny_pool_size ||= Batsir::Config.ampq_pool_size
end