Fix issue #8: allow injecting custom HTTP clients for advanced transport and retry logic#15
Open
Deadpool2000 wants to merge 2 commits intoopenapi:mainfrom
Open
Fix issue #8: allow injecting custom HTTP clients for advanced transport and retry logic#15Deadpool2000 wants to merge 2 commits intoopenapi:mainfrom
Deadpool2000 wants to merge 2 commits intoopenapi:mainfrom
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.
Hey @francescobianco
This PR addresses an issue where the SDK was tightly coupled to its own internal instantiation of
httpxclients, which made it impossible for developers to plug in custom transport adapters or specialized retry policies (likeurllib3'sRetrystrategy).What changed?
clientinjection parameter: I've updated the__init__methods for all SDK client classes (Client,AsyncClient,OauthClient, andAsyncOauthClient) to accept an optionalclientparameter.client, the SDK will safely fall back to instantiating the defaulthttpxclient just like it always has. None of the existing implementations or downstream projects will break.README.mdwith a new "Customizing the Transport Layer" section, including a practical code snippet on how to pass arequests.Sessionbundled with aurllib3max-retries adapter.Why is this important?
Providing a way to BYOC ("Bring Your Own Client") gives a lot of flexibility. It unblocks consumers of the SDK who need strict timeout rules, proxy configurations, or advanced retry strategies when interacting with our APIs in production environments.
Let me know if you have any questions or feedback.