lostisland / lostisland/faraday-net_http_persistent
How do I call Net::HTTP::Persistent.shutdown?
- Dominant language
- Ruby
- Stars
- 20
- Forks
- 9
- PR merge metrics
- No merged PRs in 30d
Description
Hello. I want to reuse a Net::HTTP connection. However, I want to destroy (close) the connection after one sequence operation.
### sample code
```ruby
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.
```ruby
conn.app.instance_variable_get(:@cached_connection).shutdown
```
Is there an easier way to destory a connection? Or is it a process that does not require destroying the connection?
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by tracing Faraday::Adapter::NetHttpPersistent.close and the @cached_connection.shutdown call shown in the issue. Confirm the supported connection-pool lifecycle and document whether callers should close or reuse the pool, including the behavior after shutdown.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- backend
- Issue type
- Documentation
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100