Class: Burrow::Connection

Inherits:
Object
  • Object
show all
Defined in:
lib/burrow/connection.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(queue_name) ⇒ Connection

Returns a new instance of Connection.



5
6
7
# File 'lib/burrow/connection.rb', line 5

def initialize(queue_name)
  @queue_name = queue_name
end

Instance Attribute Details

#queue_nameObject (readonly)

Returns the value of attribute queue_name.



3
4
5
# File 'lib/burrow/connection.rb', line 3

def queue_name
  @queue_name
end

Instance Method Details

#channelObject



17
18
19
# File 'lib/burrow/connection.rb', line 17

def channel
  @channel ||= connection.create_channel
end

#connectionObject



9
10
11
12
13
14
15
# File 'lib/burrow/connection.rb', line 9

def connection
  @connection ||= begin
    c = Bunny.new
    c.start
    c
  end
end

#exchangeObject



25
26
27
# File 'lib/burrow/connection.rb', line 25

def exchange
  @exchange ||= channel.default_exchange
end

#queueObject



21
22
23
# File 'lib/burrow/connection.rb', line 21

def queue
  @queue ||= channel.queue(queue_name, auto_delete: false)
end

#return_queueObject



29
30
31
# File 'lib/burrow/connection.rb', line 29

def return_queue
  @return_queue ||= channel.queue('', exclusive: true)
end