Allow persistent=false to be set externally #27
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR allows
connection.persistent = false
to be called externally.Use cases:
Server connections - As part of a more graceful shutdown, I want in-flight connections to be allowed to finish the current request/response, but then terminate and not be reused. In addition to closing the connection, flagging connections in this way allows them to return a
Connection: closed
header so the client is properly notified that this connection isn't to be reused for further requests.Client connections - When certain conditions are met, I want to flag client connections as not eligible to be returned to the Pool for reuse. This could be because the connection configuration has changed, a maximum request count has been reached, etc.
Alternatives
I'm not sure setting
connection.persistent = true
is ever warranted. As such, I considered adding a#not_persistent!
method instead that only sets tofalse
. I chose to go with the simpler solution of an accessor, but going with something more opinionated is an option if preferred.Types of Changes
Contribution