Skip to content

add a separate configuration struct for pool #284

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

Conversation

artemredkin
Copy link
Collaborator

Move pool idle time configuration to separate struct.

Motivation:
Right now there is only one configuration parameter for the pool, idle time, but we might have more in the future. I think it makes sense to wrap all pool-related setting in a separate struct.

Modifications:
Add PoolConfiguration struct and move idle time to that struct

Result:
All pool level settings will be in one namespace.

@artemredkin artemredkin requested a review from Lukasa July 16, 2020 16:45
@artemredkin artemredkin added this to the 1.2.0 milestone Jul 16, 2020
@Lukasa Lukasa added the 🆕 semver/minor Adds new public API. label Jul 17, 2020
@@ -860,6 +860,16 @@ extension HTTPClient.Configuration {
/// - warning: Cycle detection will keep all visited URLs in memory which means a malicious server could use this as a denial-of-service vector.
public static func follow(max: Int, allowCycles: Bool) -> RedirectConfiguration { return .init(configuration: .follow(max: max, allowCycles: allowCycles)) }
}

/// Connection pool configuration.
public struct PoolConfiguration {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we make this Hashable?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Out of curiosity, why do you think we might need it? Also, TimeAmount is not hashable, so this will require implementing hash(into:), should I add it?

Copy link
Collaborator

Choose a reason for hiding this comment

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

TimeAmount is Hashable as of 2.19.0.

Copy link
Collaborator

Choose a reason for hiding this comment

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

As to why we need it, it's not so much that we need it as that, for trivial structures, missing Equatable and Hashable conformances tend to be minor annoyances. It's nicer just to have them.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done!

@artemredkin artemredkin removed the 🆕 semver/minor Adds new public API. label Jul 17, 2020
/// Connection pool configuration.
public struct PoolConfiguration: Hashable {
// Specifies amount of time connections are kept idle in the pool.
var idleTimeout: TimeAmount
Copy link
Collaborator

Choose a reason for hiding this comment

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

Whoops, nearly missed this.

Suggested change
var idleTimeout: TimeAmount
public var idleTimeout: TimeAmount

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

🙏

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fixed!

Copy link
Collaborator

@Lukasa Lukasa left a comment

Choose a reason for hiding this comment

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

Approving, and merging over the complaints of the API checker because we haven't shipped any of the API we're breaking here.

@Lukasa Lukasa merged commit 2e6a64a into swift-server:master Jul 17, 2020
@artemredkin artemredkin deleted the pool_configuration_refactoring branch July 17, 2020 15:19
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.

2 participants