Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename connection_max_idle_time to max_idle_time #14

Merged
merged 1 commit into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ These values can be configured as follows (in seconds):

``` ruby
Fetch.configure do |config|
config.connection_max_idle_time = 10 # default
config.keep_alive_timeout = 2 # default
config.max_idle_time = 10 # default
config.keep_alive_timeout = 2 # default
end
```

Expand Down
4 changes: 2 additions & 2 deletions lib/fetch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def self.configure(&block)
end

configure do |config|
config.connection_max_idle_time = 10
config.keep_alive_timeout = 2
config.max_idle_time = 10
config.keep_alive_timeout = 2
end
end
2 changes: 1 addition & 1 deletion lib/fetch/config.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Fetch
Config = Struct.new(:connection_max_idle_time, :keep_alive_timeout)
Config = Struct.new(:max_idle_time, :keep_alive_timeout)
end
2 changes: 1 addition & 1 deletion lib/fetch/connection_pool.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def sweep
@connections.each do |origin, entry|
next if entry.in_use

if entry.last_used + Fetch.config.connection_max_idle_time < Time.now
if entry.last_used + Fetch.config.max_idle_time < Time.now
entry.connection.finish

@connections.delete origin
Expand Down
2 changes: 1 addition & 1 deletion sig/fetch/config.rbs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Fetch
class Config
attr_accessor connection_max_idle_time: Integer
attr_accessor max_idle_time: Integer
attr_accessor keep_alive_timeout: Integer
end
end
4 changes: 2 additions & 2 deletions spec/fetch/connection_pool_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
example 'reusing connections' do
pool = Fetch::ConnectionPool.new

Fetch.config.with connection_max_idle_time: 10 do
Fetch.config.with max_idle_time: 10 do
conn1 = pool.with_connection(uri, &:itself)
conn2 = pool.with_connection(uri, &:itself)

Expand All @@ -19,7 +19,7 @@
example 'closing idle connections' do
pool = Fetch::ConnectionPool.new

Fetch.config.with connection_max_idle_time: 1 do
Fetch.config.with max_idle_time: 1 do
conn1 = pool.with_connection(uri, &:itself)
sleep 2
conn2 = pool.with_connection(uri, &:itself)
Expand Down