class Legion::Transport::Exchange
Public Class Methods
new(exchange = exchange_name, options = {})
click to toggle source
Calls superclass method
# 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
Public Instance Methods
channel()
click to toggle source
# File lib/legion/transport/exchange.rb, line 61 def channel @channel ||= Legion::Transport::Connection.channel rescue ChannelLevelException => e @channel = Legion::Transport::Connection.channel raise e unless @channel.open? end
default_options()
click to toggle source
# File lib/legion/transport/exchange.rb, line 29 def default_options hash = Concurrent::Hash.new hash[:durable] = true hash[:auto_delete] = false hash[:arguments] = {} hash[:passive] = passive? hash end
default_type()
click to toggle source
# File lib/legion/transport/exchange.rb, line 57 def default_type 'topic' end
delete(options = {})
click to toggle source
Calls superclass method
# File lib/legion/transport/exchange.rb, line 50 def delete(options = {}) super(options) true rescue Legion::Transport::CONNECTOR::PreconditionFailed false end
delete_exchange(exchange)
click to toggle source
# File lib/legion/transport/exchange.rb, line 24 def delete_exchange(exchange) Legion::Transport.logger.warn "Exchange:#{exchange} exists with wrong parameters, deleting and creating" channel.exchange_delete(exchange) end
exchange_name()
click to toggle source
# File lib/legion/transport/exchange.rb, line 42 def exchange_name self.class.ancestors.first.to_s.split('::')[2].downcase end
exchange_options()
click to toggle source
# File lib/legion/transport/exchange.rb, line 46 def exchange_options Concurrent::Hash.new end
passive?()
click to toggle source
# File lib/legion/transport/exchange.rb, line 38 def passive? false end