class Cottus::Client
Attributes
connections[R]
strategy[R]
Public Class Methods
new(hosts, options={})
click to toggle source
# File lib/cottus/client.rb, line 11 def initialize(hosts, options={}) @connections = create_connections(hosts) @strategy = create_strategy(options) end
Public Instance Methods
hosts()
click to toggle source
# File lib/cottus/client.rb, line 16 def hosts @connections.map(&:host) end
Private Instance Methods
create_connections(hosts)
click to toggle source
# File lib/cottus/client.rb, line 22 def create_connections(hosts) hosts = hosts.is_a?(String) ? hosts.split(',') : hosts hosts.map { |host| Connection.new(Excon.new(host)) } end
create_strategy(options)
click to toggle source
# File lib/cottus/client.rb, line 27 def create_strategy(options) strategy_options = options[:strategy_options] || {} strategy_impl = options[:strategy] || RoundRobinStrategy strategy_impl.new(connections, strategy_options) end