Class: RubySnowflake::Client::HttpConnectionWrapper

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_snowflake/client/http_connection_wrapper.rb

Instance Method Summary collapse

Constructor Details

#initialize(hostname, port) ⇒ HttpConnectionWrapper

Returns a new instance of HttpConnectionWrapper.



8
9
10
11
# File 'lib/ruby_snowflake/client/http_connection_wrapper.rb', line 8

def initialize(hostname, port)
  @hostname = hostname
  @port = port
end

Instance Method Details

#request(request) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/ruby_snowflake/client/http_connection_wrapper.rb', line 22

def request(request)
  # connections can timeout and close, re-open them
  # which is what the connection pool expects
  start unless connection.active?

  begin
    connection.request(request)
  rescue OpenSSL::SSL::SSLError => e
    raise e # let open ssl errors propagate up to get retried
  rescue StandardError
    raise RequestError, "HTTP error requesting data"
  end
end

#startObject



13
14
15
16
17
18
19
20
# File 'lib/ruby_snowflake/client/http_connection_wrapper.rb', line 13

def start
  @connection = Net::HTTP.start(@hostname, @port, use_ssl: true)
  self
rescue OpenSSL::SSL::SSLError => e
  raise e # let open ssl errors propagate up to get retried
rescue StandardError
  raise ConnectionError.new "Error connecting to server."
end