Class: Msgr::Binding
Instance Attribute Summary collapse
-
#channel ⇒ Object
readonly
Returns the value of attribute channel.
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
-
#dispatcher ⇒ Object
readonly
Returns the value of attribute dispatcher.
-
#queue ⇒ Object
readonly
Returns the value of attribute queue.
-
#route ⇒ Object
readonly
Returns the value of attribute route.
Instance Method Summary collapse
- #delete ⇒ Object
-
#initialize(connection, route, dispatcher) ⇒ Binding
constructor
A new instance of Binding.
- #purge(release: true) ⇒ Object
- #release ⇒ Object
Methods included from Logging
Constructor Details
#initialize(connection, route, dispatcher) ⇒ Binding
Returns a new instance of Binding.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/msgr/binding.rb', line 16 def initialize(connection, route, dispatcher) @connection = connection @channel = connection.channel(prefetch: route.prefetch) @route = route @dispatcher = dispatcher @queue = @channel.queue(route.name) route.keys.each do |key| log(:debug) { "Bind #{key} to #{queue.name}." } queue.bind @channel.exchange, routing_key: key end subscribe end |
Instance Attribute Details
#channel ⇒ Object (readonly)
Returns the value of attribute channel.
7 8 9 |
# File 'lib/msgr/binding.rb', line 7 def channel @channel end |
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
7 8 9 |
# File 'lib/msgr/binding.rb', line 7 def connection @connection end |
#dispatcher ⇒ Object (readonly)
Returns the value of attribute dispatcher.
7 8 9 |
# File 'lib/msgr/binding.rb', line 7 def dispatcher @dispatcher end |
#queue ⇒ Object (readonly)
Returns the value of attribute queue.
7 8 9 |
# File 'lib/msgr/binding.rb', line 7 def queue @queue end |
#route ⇒ Object (readonly)
Returns the value of attribute route.
7 8 9 |
# File 'lib/msgr/binding.rb', line 7 def route @route end |
Instance Method Details
#delete ⇒ Object
36 37 38 39 |
# File 'lib/msgr/binding.rb', line 36 def delete release queue.delete end |
#purge(release: true) ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/msgr/binding.rb', line 41 def purge(release: true) self.release if release queue.purge subscribe if release end |
#release ⇒ Object
32 33 34 |
# File 'lib/msgr/binding.rb', line 32 def release subscription.cancel end |