Skip to content

Avoid registering the strategy listener when it is useless #141

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
merged 1 commit into from
Apr 26, 2017

Conversation

stof
Copy link
Contributor

@stof stof commented Apr 5, 2017

Q A
Bug fix? no
New feature? no
BC breaks? no
Deprecations? no
Related tickets n/a
Documentation n/a
License MIT

If both the client and the async client are null, the strategy would never find any candidates. In such case, it is useless to register it as a kernel.request listener to prepend itself to the discovery, as it would not have any effect on the discovery, but it requires work on each request.

If both the client and the async client are null, the strategy would never
find any candidates. In such case, it is useless to register it as a
kernel.request listener to prepend itself to the discovery.
@fbourigault
Copy link
Contributor

The service is public. I hope anybody rely on it, but in such case is it considered as a BC break? IMHO, it requires at least a note in the CHANGELOG.

@stof
Copy link
Contributor Author

stof commented Apr 5, 2017

Well, it is public because event listeners are required to be public (in Symfony < 3.3). But getting this service in your own code is totally useless as it is about 2 things:

  • being a discovery strategy (which is an internal part of the discovery itself, and so people should not call it directly), and even a useless strategy in the case where it is removed (why would you call an internal service of another bundle when you wrote explicit configuration to make it always return an empty array). Thus, the strategy part is a static API so people might not even be calling the service.
  • being an event listener to register the strategy (which is the part doing useless work).

Thus, this service is never documented anywhere.
And being in the case of removal requires explicit configuration. By default, the client discovery is in auto mode (which implies instantiating a client on each kernel.request event to configure the strategy, even when discovery is never used later. Plus it could be too late for the discovery call if they are used for a service needed earlier than this call, which makes the whole feature questionable btw). The removal only happens with this config:

httplug:
    discovery:
        client: null

I will let maintainers decide whether this deserves a changelog note or no (the changelog note might be more confusing than anything else for most people.)

Copy link
Collaborator

@dbu dbu left a comment

Choose a reason for hiding this comment

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

i think this makes sense, and agree we don't need a changelog entry. the one person that might has been using it will realize it or come and ask.

@fbourigault fbourigault self-requested a review April 18, 2017 07:22
@dbu dbu merged commit 40acadf into php-http:master Apr 26, 2017
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.

3 participants