lib/legion/extensions/transport.rb in legionio-0.3.0 vs lib/legion/extensions/transport.rb in legionio-0.3.1
- old
+ new
@@ -1,9 +1,10 @@
module Legion
module Extensions
module Transport
include Legion::Extensions::Helpers::Transport
+ include Legion::Extensions::Helpers::Logger
attr_accessor :exchanges, :queues, :consumers, :messages
def build
@queues = []
@@ -86,16 +87,17 @@
end
def build_e_to_q(array)
array.each do |binding|
binding[:routing_key] = nil unless binding.key? :routing_key
- binding[:to] = nil unless binding.key? :to
+ binding[:to] = nil unless binding.key?(:to)
+ binding[:from] = default_exchange if !binding.key?(:from) || binding[:from].nil?
bind_e_to_q(**binding)
end
end
- def bind_e_to_q(to:, from: default_exchange, routing_key: nil)
+ def bind_e_to_q(to:, from: default_exchange, routing_key: nil, **)
if from.is_a? String
from = "#{transport_class}::Exchanges::#{from.split('_').collect(&:capitalize).join}" unless from.include?('::')
auto_create_exchange(from) unless Object.const_defined? from
end
@@ -127,12 +129,12 @@
def bind(from, to, routing_key: nil, **_options)
from = from.is_a?(String) ? Kernel.const_get(from).new : from.new
to = to.is_a?(String) ? Kernel.const_get(to).new : to.new
to.bind(from, routing_key: routing_key)
rescue StandardError => e
- Legion::Logging.fatal e.message
- Legion::Logging.fatal e.backtrace
- Legion::Logging.fatal({ from: from, to: to, routing_key: routing_key })
+ log.fatal e.message
+ log.fatal e.backtrace
+ log.fatal({ from: from, to: to, routing_key: routing_key })
end
def e_to_q
[] if !@exchanges.count != 1
auto = []