class EventStore::HTTP::Connect

Public Class Methods

build(settings=nil, namespace: nil) click to toggle source
# File lib/event_store/http/connect.rb, line 19
def self.build(settings=nil, namespace: nil)
  settings ||= Settings.instance
  namespace ||= Array(namespace)

  instance = new
  settings.set instance, namespace
  instance
end
call(ip_address=nil, settings: nil, namespace: nil) click to toggle source
# File lib/event_store/http/connect.rb, line 28
def self.call(ip_address=nil, settings: nil, namespace: nil)
  instance = build settings, namespace: namespace
  instance.(ip_address)
end
configure_connection(receiver, settings=nil, connection: nil, attr_name: nil, **arguments) click to toggle source
# File lib/event_store/http/connect.rb, line 33
def self.configure_connection(receiver, settings=nil, connection: nil, attr_name: nil, **arguments)
  attr_name ||= :connection

  connection ||= self.(settings: settings, **arguments)
  receiver.public_send "#{attr_name}=", connection
  connection
end

Public Instance Methods

call(ip_address=nil) click to toggle source
# File lib/event_store/http/connect.rb, line 41
def call(ip_address=nil)
  if ip_address.nil?
    connect
  else
    raw ip_address
  end
end
connect() click to toggle source
# File lib/event_store/http/connect.rb, line 49
def connect
  raw host
end
port() click to toggle source
# File lib/event_store/http/connect.rb, line 15
def port
  @port ||= Defaults.port
end
raw(ip_address) click to toggle source
# File lib/event_store/http/connect.rb, line 53
def raw(ip_address)
  logger.trace { "Building Net::HTTP connection (IPAddress: #{ip_address}, Port: #{port})" }

  net_http = Net::HTTP.new ip_address, port
  net_http.keep_alive_timeout = keep_alive_timeout unless keep_alive_timeout.nil?
  net_http.open_timeout = open_timeout unless open_timeout.nil?
  net_http.read_timeout = read_timeout unless read_timeout.nil?

  logger.debug { "Net::HTTP connection built (IPAddress: #{ip_address}, Port: #{port})" }

  net_http.extend NetHTTP::Extensions

  net_http
end