Hello. I want to reuse a Net::HTTP connection. However, I want to destroy (close) the connection after one sequence operation.
sample code
conn = Faraday.new do |f|
f.adapter :net_http_persistent, pool_size: 5 do |http|
http.idle_timeout = 5
end
end
conn.get('http://example.com/1')
conn.get('http://example.com/2') # reuse connection
conn.get('http://example.com/3') # reuse connection, end of sequence
conn.close # I want to destroy connection pool
# create new connection pool
conn = Faraday.new do |f|
f.adapter :net_http_persistent, pool_size: 5 do |http|
http.idle_timeout = 5
end
end
conn.get('http://example.com/1')
conn.get('http://example.com/2') # reuse connection
conn.get('http://example.com/3') # reuse connection, end of sequence
conn.close # I want to destroy connection pool
I think the conn.close method is just calling Faraday::Adapter::NetHttpPersistent.close. And Faraday::Adapter::NetHttpPersistent.close is not implemented.
I think calling @cached_connection.shutdown is destory connections, Like this.
Hello. I want to reuse a Net::HTTP connection. However, I want to destroy (close) the connection after one sequence operation.
sample code
I think the
conn.close
method is just callingFaraday::Adapter::NetHttpPersistent.close
. AndFaraday::Adapter::NetHttpPersistent.close
is not implemented.I think calling
@cached_connection.shutdown
is destory connections, Like this.Is there an easier way to destory a connection? Or is it a process that does not require destroying the connection?