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.



4
5
6
7
# File 'lib/ruby_snowflake/client/http_connection_wrapper.rb', line 4

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

Instance Method Details

#request(request) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/ruby_snowflake/client/http_connection_wrapper.rb', line 16

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 StandardError => error
    raise RequestError.new "HTTP error requesting data", cause: error
  end
end

#startObject



9
10
11
12
13
14
# File 'lib/ruby_snowflake/client/http_connection_wrapper.rb', line 9

def start
  @connection = Net::HTTP.start(@hostname, @port, use_ssl: true)
  self
rescue StandardError
  raise ConnectionError.new "Error connecting to server."
end