Class: Hutch::Adapters::MarchHareAdapter
- Inherits:
-
Object
- Object
- Hutch::Adapters::MarchHareAdapter
- Extended by:
- Forwardable
- Defined in:
- lib/hutch/adapters/march_hare.rb
Constant Summary collapse
- DEFAULT_VHOST =
"/"- ConnectionRefused =
MarchHare::ConnectionRefused
- ChannelAlreadyClosed =
MarchHare::ChannelAlreadyClosed
- PreconditionFailed =
MarchHare::PreconditionFailed
Class Method Summary collapse
- .decode_message(delivery_info, payload) ⇒ Object
- .new_exchange(ch, exchange_type, exchange_name, exchange_options) ⇒ Object
Instance Method Summary collapse
- #create_channel(n = nil, consumer_pool_size = 1, consumer_pool_abort_on_exception = false) ⇒ Object
- #current_timestamp ⇒ Object
-
#initialize(opts = {}) ⇒ MarchHareAdapter
constructor
A new instance of MarchHareAdapter.
-
#install_channel_recovery(ch) ⇒ Object
MarchHare::Channel has no on_error callback, and neither Channel#reopen nor Session#recover_channel_topology has a
march_harecounterpart. - #prefetch_channel(ch, prefetch) ⇒ Object
-
#queue_exists?(name) ⇒ Boolean
MarchHare::Sessionhas noqueue_exists?counterpart, and a failed passive declare closes the channel, hence the throwaway one.
Constructor Details
#initialize(opts = {}) ⇒ MarchHareAdapter
Returns a new instance of MarchHareAdapter.
17 18 19 |
# File 'lib/hutch/adapters/march_hare.rb', line 17 def initialize(opts = {}) @connection = MarchHare.connect(opts) end |
Class Method Details
.decode_message(delivery_info, payload) ⇒ Object
21 22 23 |
# File 'lib/hutch/adapters/march_hare.rb', line 21 def self.(delivery_info, payload) [delivery_info, delivery_info.properties, payload] end |
.new_exchange(ch, exchange_type, exchange_name, exchange_options) ⇒ Object
56 57 58 |
# File 'lib/hutch/adapters/march_hare.rb', line 56 def self.new_exchange(ch, exchange_type, exchange_name, ) MarchHare::Exchange.new(ch, exchange_name, .merge(type: exchange_type)).tap(&:declare!) end |
Instance Method Details
#create_channel(n = nil, consumer_pool_size = 1, consumer_pool_abort_on_exception = false) ⇒ Object
48 49 50 |
# File 'lib/hutch/adapters/march_hare.rb', line 48 def create_channel(n = nil, consumer_pool_size = 1, consumer_pool_abort_on_exception = false) @connection.create_channel(n) end |
#current_timestamp ⇒ Object
52 53 54 |
# File 'lib/hutch/adapters/march_hare.rb', line 52 def Time.now end |
#install_channel_recovery(ch) ⇒ Object
MarchHare::Channel has no on_error callback, and neither Channel#reopen
nor Session#recover_channel_topology has a march_hare counterpart.
45 46 |
# File 'lib/hutch/adapters/march_hare.rb', line 45 def install_channel_recovery(ch) end |
#prefetch_channel(ch, prefetch) ⇒ Object
25 26 27 |
# File 'lib/hutch/adapters/march_hare.rb', line 25 def prefetch_channel(ch, prefetch) ch.prefetch = prefetch if prefetch end |
#queue_exists?(name) ⇒ Boolean
MarchHare::Session has no queue_exists? counterpart, and a failed
passive declare closes the channel, hence the throwaway one.
31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/hutch/adapters/march_hare.rb', line 31 def queue_exists?(name) ch = @connection.create_channel begin ch.queue(name, passive: true) true rescue MarchHare::NotFound false ensure ch.close rescue nil end end |