Add support for transport sharing - #3335
Open
GrahamCampbell wants to merge 2 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Guzzle 8 added transport sharing, which lets the built-in handlers share DNS, SSL session, and connection cache state, including persistent cURL share handles on PHP 8.5+ that survive across php-fpm requests. Guzzle 7.11 supports the handler-lifetime subset of the feature. This PR exposes the capability through a new
transport_sharingclient option with five string modes matching Guzzle's vocabulary:none,handler_prefer,handler_require,persistent_prefer, andpersistent_require.The option's semantics are independent of the installed Guzzle version. The SDK feature-detects what the installed Guzzle supports, degrades the prefer modes gracefully (
persistent_preferfalls back to handler-lifetime sharing on Guzzle 7.11+ and to no sharing on older versions), and throws for the require modes when they cannot be honored, sopersistent_requireis a deployment assertion that connection re-use is actually happening. The option applies when the SDK creates the default HTTP handler, since transport sharing is configured on the Guzzle client constructor rather than per request, and the require modes reject customhandlerorhttp_handleroptions.Aws\Sdkapplies the option to the HTTP handler it shares across the clients it creates. The nametransport_sharingmirrors Guzzle's client option; renaming it tohttp_transport_sharingto group with the other HTTP options would be a two-token change if preferred. A separate commit adds a CI matrix leg pinning Guzzle to>=7.11 <8so the handler-lifetime degradation path is exercised; it can be dropped if unwanted, since the affected tests skip themselves based on feature detection.By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.