-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[FrameworkBundle][HttpClient] Refactor http_client decoration strategy #49513
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
Conversation
fancyweb
commented
Feb 23, 2023
Q | A |
---|---|
Branch? | 6.3 |
Bug fix? | no |
New feature? | no |
Deprecations? | no |
Tickets | #49302 (comment) |
License | MIT |
Doc PR | - |
src/Symfony/Component/HttpClient/DependencyInjection/HttpClientPass.php
Outdated
Show resolved
Hide resolved
Rebase unlocked after #49302 |
52e5f75
to
237f7b6
Compare
237f7b6
to
11e2164
Compare
src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
Show resolved
Hide resolved
@@ -2413,7 +2406,7 @@ private function registerHttpClientConfiguration(array $config, ContainerBuilder | |||
->register($name.'.uri_template', UriTemplateHttpClient::class) | |||
->setDecoratedService($name, null, 7) // Between TraceableHttpClient (5) and RetryableHttpClient (10) | |||
->setArguments([ | |||
new Reference('.inner'), | |||
new Reference($name.'.uri_template.inner'), |
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.
let's be consistent with the rest of the file
|
||
->set('http_client', HttpClientInterface::class) | ||
->factory('current') | ||
->args([[service('http_client.transport')]]) |
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.
Here is the master trick of this PR :)
This creates what I'd call a "tagged alias".
Thank you @fancyweb. |
… used as service factory (nicolas-grekas) This PR was merged into the 6.3 branch. Discussion ---------- [DependencyInjection] Optimize out "current()" when it's used as service factory | Q | A | ------------- | --- | Branch? | 6.3 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - Sometimes, we need to use the "identity function" as a service factory. One example is #49513, where we use that to create a "tagged alias". In PHP, the identity function is `current([$foo])`. Let's optimize out such calls. Commits ------- 834a550 [DependencyInjection] Optimize out "current()" when it's used as service factory
… (HypeMC) This PR was merged into the 6.4 branch. Discussion ---------- [HttpClient] Fix `reset()` not called on decorated clients | Q | A | ------------- | --- | Branch? | 6.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | - | License | MIT This was broken in #49513 for the main HTTP client and, as far as I can tell, never worked for scoped clients. The problem is that some decorator clients, like the `ThrottlingHttpClient`, have their own `reset()` method, which never gets called when using the `services_resetter` service. Scoped clients don't decorate the main one but instead use it as a dependency. Commits ------- 8f5f98a [HttpClient] Fix reset not called on decorated clients