Method: Bunny::Session#addresses_from

Defined in:
lib/bunny/session.rb

#addresses_from(options) ⇒ Object



932
933
934
935
936
937
938
939
940
941
942
943
944
# File 'lib/bunny/session.rb', line 932

def addresses_from(options)
  shuffle_strategy = options.fetch(:hosts_shuffle_strategy, @default_hosts_shuffle_strategy)

  addresses = options[:host] || options[:hostname] || options[:addresses] ||
    options[:hosts] || ["#{DEFAULT_HOST}:#{port_from(options)}"]
  addresses = [addresses] unless addresses.is_a? Array

  addrs = addresses.map do |address|
    host_with_port?(address) ? address : "#{address}:#{port_from(@opts)}"
  end

  shuffle_strategy.call(addrs)
end