-
Notifications
You must be signed in to change notification settings - Fork 50
Use xml to configure discovered clients #183
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
Use xml to configure discovered clients #183
Conversation
$httpClient = new Reference($httpClient); | ||
if (!empty($httpClient) && $httpClient !== 'auto') { | ||
$container->setAlias('httplug.auto_discovery.auto_discovered_client', $httpClient); | ||
} elseif (null === $httpClient) { |
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.
Why "elseif"?
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.
Because possible values are null
, auto
or any configured client name. So the first case handle the "any configured client name" and the elseif the null case which means remove the definition from the container.
$asyncHttpClient = new Reference($asyncHttpClient); | ||
if (!empty($asyncHttpClient) && $asyncHttpClient !== 'auto') { | ||
$container->setAlias('httplug.auto_discovery.auto_discovered_async', $asyncHttpClient); | ||
} elseif (null === $asyncHttpClient) { |
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.
Same here..
$container->setAlias('httplug.auto_discovery.auto_discovered_async', $asyncHttpClient); | ||
} elseif (null === $asyncHttpClient) { | ||
$container->removeDefinition('httplug.auto_discovery.auto_discovered_async'); | ||
$container->removeDefinition('httplug.collector.auto_discovered_async'); | ||
} | ||
|
||
if (null === $httpClient && null === $asyncHttpClient) { |
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.
Is this check still valid?
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.
Yes, If we have no discovered client (sync and async), we remove the useless listener.
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.
looks a lot more readable to me.
an alternative to removing the definitions from the container could be to use separate files that we only load when the respective client is active. given the size of the xml file, i think it could be a good idea to split those out. wdyt?
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.
Will this make the code even easier to read?
} | ||
|
||
$httpClient = new Reference($httpClient); | ||
if (!empty($httpClient) && $httpClient !== 'auto') { |
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.
if ($httpClient !== 'auto') {
//...
if (!empty($httpClient) {
//...
}
}
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.
I don't used to write nested conditions (object calisthenics ❤️) but I will make an exception.
I've update the code to make #184 tests fine. About conditional xml loading, I don't think it worth it. I would need to load 5 different files ( I think it would be easier later as the profiling stuff will be handled differently (in the PluginClientFactory injected factory callback). |
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.
i think this is a good improvement. lets merge as is. we can look at maybe splitting config files in a separate pull request.
Thank you for reviews! |
This move discovered clients configuration from
HttplugExtension
toservices.xml
anddata-collector.xml
.To Do