-
Notifications
You must be signed in to change notification settings - Fork 123
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
Close idle pool connections #170
Conversation
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
@@ -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? |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
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), |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 ?
There was a problem hiding this 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
Fixes the race condition and adds a new test for it
pollingTimeout to maximumAllowedIdleTimeInConnectionPool
There was a problem hiding this 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 :|
test delayed close
This should fix the race. Deterministic tests are not possible with the current implementation
There was a problem hiding this 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!
There was a problem hiding this 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!
Motivation: Pooled connections should close at some point (see #168)
Changes:
maximumAllowedIdleTimeInConnectionPool
property toHTTPClient.Configuration
, its default value is currently.seconds(60)
, and it can be set tonil
if one wishes to disable this timeout.