Skip to content

Close idle pool connections #170

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

Merged
merged 18 commits into from
Mar 3, 2020
Merged

Close idle pool connections #170

merged 18 commits into from
Mar 3, 2020

Conversation

PopFlamingo
Copy link
Contributor

@PopFlamingo PopFlamingo commented Feb 26, 2020

Motivation: Pooled connections should close at some point (see #168)

Changes:

  • Add new maximumAllowedIdleTimeInConnectionPool property to HTTPClient.Configuration, its default value is currently .seconds(60), and it can be set to nil if one wishes to disable this timeout.
  • Add relevant unit test
  • Closes connection pool: idle connection never closed #168

Motivation: Pooled connections should close at some point (see #168)

Changes:
- Add new poolingTimeout property to HTTPClient.Configuration, it's
default value is .seconds(60), it can be set to nil if one wishes to
disable this timeout.
- Add relevant unit test
@PopFlamingo PopFlamingo changed the title Idle pool connection close Close idle pool connections Feb 26, 2020
@@ -408,6 +409,8 @@ public class HTTPClient {
public var redirectConfiguration: RedirectConfiguration
/// Default client timeout, defaults to no timeouts.
public var timeout: Timeout
/// Timeout of pooled connections
public var poolingTimeout: TimeAmount?
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a good name for this setting?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd make it a bit longer and more descriptive. Maybe maximumAllowedIdleTimeInConnectionPool or so? @Lukasa ?

Copy link
Contributor Author

@PopFlamingo PopFlamingo Feb 26, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I set it to this for now, thanks.

tlsConfiguration: tlsConfiguration,
redirectConfiguration: redirectConfiguration,
timeout: timeout,
poolingTimeout: .seconds(60),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think of the default 60 seconds timeout?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm okay with this, @Lukasa ?

Copy link
Contributor

@weissi weissi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like a great start

Copy link
Contributor

@weissi weissi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks really good but found another small race :|

weissi and others added 5 commits February 27, 2020 19:08
This should fix the race.
Deterministic tests are not possible with the current implementation
Copy link
Contributor

@weissi weissi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, this is really close!

@PopFlamingo PopFlamingo requested a review from weissi March 3, 2020 21:15
Copy link
Contributor

@weissi weissi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thanks so much!

@weissi weissi merged commit 9cdd1dc into swift-server:master Mar 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

connection pool: idle connection never closed
2 participants