Class: Legion::Transport::Exchange
- Inherits:
-
CONNECTOR::Exchange
- Object
- CONNECTOR::Exchange
- Legion::Transport::Exchange
show all
- Includes:
- Common
- Defined in:
- lib/legion/transport/exchange.rb
Instance Method Summary
collapse
Methods included from Common
#channel, #channel_open?, #close, #close!, #deep_merge, #generate_consumer_tag, #open_channel, #options_builder
Constructor Details
#initialize(exchange = exchange_name, options = {}) ⇒ Exchange
Returns a new instance of Exchange.
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/legion/transport/exchange.rb', line 6
def initialize(exchange = exchange_name, options = {})
@options = options
@type = options[:type] || default_type
if Legion::Transport::TYPE == 'march_hare'
super_options = options_builder(default_options, exchange_options, @options)
super_options[:type] = @type
super(channel, exchange, **super_options)
else
super(channel, @type, exchange, options_builder(default_options, exchange_options, @options))
end
rescue Legion::Transport::CONNECTOR::PreconditionFailed, Legion::Transport::CONNECTOR::ChannelAlreadyClosed
raise unless @retries.nil?
@retries = 1
delete_exchange(exchange)
retry
end
|
Instance Method Details
#default_options ⇒ Object
29
30
31
32
33
34
35
|
# File 'lib/legion/transport/exchange.rb', line 29
def default_options
hash = {}
hash[:durable] = true
hash[:auto_delete] = false
hash[:arguments] = {}
hash
end
|
#default_type ⇒ Object
52
53
54
|
# File 'lib/legion/transport/exchange.rb', line 52
def default_type
'topic'
end
|
#delete(options = {}) ⇒ Object
45
46
47
48
49
50
|
# File 'lib/legion/transport/exchange.rb', line 45
def delete(options = {})
super(options)
true
rescue Legion::Transport::CONNECTOR::PreconditionFailed
false
end
|
#delete_exchange(exchange) ⇒ Object
24
25
26
27
|
# File 'lib/legion/transport/exchange.rb', line 24
def delete_exchange(exchange)
Legion::Logging.warn "Exchange:#{exchange} exists with wrong parameters, deleting and creating"
channel.exchange_delete(exchange)
end
|
#exchange_name ⇒ Object
37
38
39
|
# File 'lib/legion/transport/exchange.rb', line 37
def exchange_name
self.class.ancestors.first.to_s.split('::')[2].downcase
end
|
#exchange_options ⇒ Object
41
42
43
|
# File 'lib/legion/transport/exchange.rb', line 41
def exchange_options
{}
end
|