-
Notifications
You must be signed in to change notification settings - Fork 117
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
Make ConnectionPool's retryConnectionEstablishment
public
#744
Conversation
…alizer of `HTTPClient.Configuration.ConnectionPool`
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.
Very nice, thank you! Just a single quick note.
|
||
public init(idleTimeout: TimeAmount = .seconds(60)) { | ||
self.init(idleTimeout: idleTimeout, concurrentHTTP1ConnectionsPerHostSoftLimit: 8) | ||
} | ||
|
||
public init(idleTimeout: TimeAmount, concurrentHTTP1ConnectionsPerHostSoftLimit: Int) { | ||
public init(idleTimeout: TimeAmount, concurrentHTTP1ConnectionsPerHostSoftLimit: Int, retryConnectionEstablishment: Bool = true) { |
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.
Unfortunately it's not API stable to add this extra parameter. Rather than us keep proliferating new init
s, it might be nice for us to just add a zero-element initializer and encourage users towards setting the fields after default construction.
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.
Thanks for taking a look! I've...
- Reverted the change to the existing initializer.
- Added a parameterless initializer.
- Removed the default value for the parameter
idleTimeout
in the respective initializer (because it overlaps with the new parameterless initializer). Is that safe in terms of API stability? - Moved the default values to the respective property declarations (to prevent them having to be specified at multiple points in the initializer code). This seems cleaner to me than initializer delegation, but if you prefer a different style, let me know.
@swift-server-bot test this please |
… the property declarations, so they only have to be specified at one point
@swift-server-bot test this please |
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.
Basically fine, one quick note.
Co-authored-by: Cory Benfield <[email protected]>
@swift-server-bot test this please |
I'm ignoring API breakage here: it's concerned about us removing the default argument, but we've replaced it with a zero-argument constructor so it's safe from an API perspective. |
Currently, there is no way to instantly return when a connection attempt fails. The connection timeout is always awaited, regardless of the connection error. When used within a service, this behavior makes sense – network conditions may temporarily prevent establishing a connection. However, in a user-interactive environment, it's preferable to fail quickly and display the error to the user.
#625 introduced the property
retryConnectionEstablishment
, which defaults totrue
but can be set tofalse
to not retry on connection failure. The property was added to speed up unit tests, but would also be suitable for the use-case mentioned above.This PR makes the property
retryConnectionEstablishment
, which is already documented and well tested,public
.This would fix #743.
The PR also cleans up some unit tests to consistently use
enableFastFailureModeForTesting()
instead of settingretryConnectionEstablishment
directly.Questions:
networkFrameworkWaitForConnectivity
also needs to be set tofalse
to enable fast fail. Would it be worthwhile to have the ability to set both properties at once?