Class: ActivePublisher::Async::InMemoryAdapter::Channel
- Inherits:
-
Object
- Object
- ActivePublisher::Async::InMemoryAdapter::Channel
- Defined in:
- lib/active_publisher/async/in_memory_adapter/channel.rb
Overview
This class is a wrapper around bunny and march hare channels to cache exchanges. Bunny does this by default, but march hare will perform a blocking wait for each exchange declaration.
Instance Attribute Summary collapse
-
#rabbit_channel ⇒ Object
readonly
Returns the value of attribute rabbit_channel.
-
#topic_exchange_cache ⇒ Object
readonly
Returns the value of attribute topic_exchange_cache.
Instance Method Summary collapse
- #close ⇒ Object
- #confirm_select ⇒ Object
-
#initialize ⇒ Channel
constructor
A new instance of Channel.
- #topic(exchange) ⇒ Object
- #using_publisher_confirms? ⇒ Boolean
- #wait_for_confirms(timeout) ⇒ Object
Constructor Details
#initialize ⇒ Channel
Returns a new instance of Channel.
12 13 14 15 |
# File 'lib/active_publisher/async/in_memory_adapter/channel.rb', line 12 def initialize @topic_exchange_cache = {} @rabbit_channel = ::ActivePublisher::Connection.connection.create_channel end |
Instance Attribute Details
#rabbit_channel ⇒ Object (readonly)
Returns the value of attribute rabbit_channel.
10 11 12 |
# File 'lib/active_publisher/async/in_memory_adapter/channel.rb', line 10 def rabbit_channel @rabbit_channel end |
#topic_exchange_cache ⇒ Object (readonly)
Returns the value of attribute topic_exchange_cache.
10 11 12 |
# File 'lib/active_publisher/async/in_memory_adapter/channel.rb', line 10 def topic_exchange_cache @topic_exchange_cache end |
Instance Method Details
#close ⇒ Object
17 18 19 |
# File 'lib/active_publisher/async/in_memory_adapter/channel.rb', line 17 def close rabbit_channel.close end |
#confirm_select ⇒ Object
21 22 23 |
# File 'lib/active_publisher/async/in_memory_adapter/channel.rb', line 21 def confirm_select rabbit_channel.confirm_select end |
#topic(exchange) ⇒ Object
25 26 27 |
# File 'lib/active_publisher/async/in_memory_adapter/channel.rb', line 25 def topic(exchange) topic_exchange_cache[exchange] ||= rabbit_channel.topic(exchange) end |
#using_publisher_confirms? ⇒ Boolean
29 30 31 |
# File 'lib/active_publisher/async/in_memory_adapter/channel.rb', line 29 def using_publisher_confirms? rabbit_channel.using_publisher_confirms? end |
#wait_for_confirms(timeout) ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/active_publisher/async/in_memory_adapter/channel.rb', line 33 def wait_for_confirms(timeout) if rabbit_channel.method(:wait_for_confirms).arity > 0 rabbit_channel.wait_for_confirms(timeout) else rabbit_channel.wait_for_confirms end end |