Skip to content

Commit a309a32

Browse files
committed
Do all http building in Client#build_http
1 parent 8df479a commit a309a32

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

lib/influxdb/client/http.rb

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,12 @@ def post(url, data)
4040
private
4141

4242
def connect_with_retry
43-
host = config.next_host
4443
delay = config.initial_delay
4544
retry_count = 0
4645

47-
begin
48-
http = build_http(host, config.port)
49-
http.open_timeout = config.open_timeout
50-
http.read_timeout = config.read_timeout
46+
http = build_http
5147

52-
http = setup_ssl(http)
48+
begin
5349
yield http
5450
rescue *InfluxDB::NON_RECOVERABLE_EXCEPTIONS => e
5551
raise InfluxDB::ConnectionError, InfluxDB::NON_RECOVERABLE_MESSAGE
@@ -136,12 +132,23 @@ def generate_cert_store
136132

137133
# Builds an http instance, taking into account any configured
138134
# proxy configuration
139-
def build_http(host, port)
140-
if config.proxy_addr
141-
Net::HTTP.new(host, port, config.proxy_addr, config.proxy_port)
142-
else
143-
Net::HTTP.new(host, port)
144-
end
135+
def build_http
136+
host = config.next_host
137+
port = config.port
138+
139+
http =
140+
if config.proxy_addr
141+
Net::HTTP.new(host, port, config.proxy_addr, config.proxy_port)
142+
else
143+
Net::HTTP.new(host, port)
144+
end
145+
146+
http.open_timeout = config.open_timeout
147+
http.read_timeout = config.read_timeout
148+
149+
setup_ssl http
150+
151+
http
145152
end
146153
end
147154
# rubocop:enable Metrics/MethodLength

0 commit comments

Comments
 (0)