-
Notifications
You must be signed in to change notification settings - Fork 50
Allow to configure plugins specifically for a client #112
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
6c98e84
to
70e599e
Compare
$decoder->canBeEnabled(); | ||
} else { | ||
$decoder->canBeDisabled(); | ||
} |
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.
this construct is repeated quite a bit, but i can't think of a better solution. the global plugins need to be enabled by default, but on the client, we want to only see plugins that where explicitly configured.
@@ -145,7 +158,9 @@ private function configurePluginByName($name, Definition $definition, array $con | |||
$definition->replaceArgument(0, new Reference($config['cookie_jar'])); | |||
break; | |||
case 'decoder': | |||
$definition->addArgument($config['use_content_encoding']); | |||
$definition->addArgument([ | |||
'use_content_encoding' => $config['use_content_encoding'], |
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.
separated the bugfix into #113 and then realized we have other changes in master already, so we won't do a patch release for the fix. but i guess after we merge this we want to tag 1.3 very soon so the bugfix will be released soon.
How can you control the order of plugins? Maybe we can have this within the plugins section: numeric index: look for service, string index: configure extra plugin. |
110f452
to
64a3ebb
Compare
without further information, extra_plugins are appended to the explicitly configured plugins in the order they have been defined. but you can specify each of the extra_plugin in the |
Maybe we can have this within the plugins section: numeric index: look
for service, string index: configure extra plugin.
ah, now i see what you mean. if we want to mix, i would rather say that
inside client.{name}.plugins you can have string (= service id) or extra
plugin configuration. this will make it easier to handle the ordering.
the drawback would be that the configuration format is different from
shared plugins, we would need to add a type field.
or we have something like this:
```
plugins:
logger:
...
client:
acme:
plugins:
- add_host:
host: ...
- httplug.plugin.logger
```
i think this last option is probably the most user friendly. (but i am
scared how to express that in the configuration definition :-( )
|
I like this approach: plugins:
logger:
...
client:
acme:
plugins:
- add_host:
host: ...
- httplug.plugin.logger It makes more sense. But yes, the configuration.php is going to be difficult. But we should try. |
64a3ebb
to
e101865
Compare
@@ -9,6 +9,7 @@ | |||
|
|||
### Added | |||
|
|||
- You can now configure plugins on each client in `extra_plugins`. Plugins that you previously had to define your own services can be configured on the client. |
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.
needs update
deb2ba2
to
9a1e3a1
Compare
->scalarNode('retry')->defaultValue(1)->end() | ||
->end() | ||
->end() // End retry plugin | ||
// TODO add aditional plugins that are only usable on a specific client |
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.
what are the plugins we should allow to configure?
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.
HeaderSet, HeaderRemove, HeaderDefaults, HeaderAppend, ContentLength
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.
ContentLength is globally available and has no configuration options. did you mean something else?
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.
No, my bad.
9a1e3a1
to
50a90f9
Compare
The plugin_journal expects a single dimensional array at https://github.com/php-http/HttplugBundle/pull/112/files#diff-18f3f26a96b967c0a5a3e13086d8367dR256 (Try to open the web profiler page and you will see an error) |
$this->configureClients($container, $config); | ||
$this->configureSharedPlugins($container, $config['plugins']); // must be after clients, as the extra_plugins in clients might use plugins as template that will be removed |
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.
Update this comment. We cant use (extra_plugins)
I've reviewed this. It is a really good improvement. I like the way you add the shared configuration on each client in the Configuration.php. I made a few comments, It was a bug but otherwise it looks fine. For the record. Here is a working configuration (we do not use httplug:
plugins:
logger:
enabled: true
logger: 'logger'
formatter: null
redirect:
enabled: true
preserve_header: true
use_default_for_multiple: true
retry:
enabled: true
retry: 1
clients:
todo:
factory: "httplug.factory.guzzle6"
plugins:
- 'httplug.plugin.logger'
- 'httplug.plugin.redirect'
- add_host:
host: http://localhost
- 'httplug.plugin.retry'
acme:
factory: 'httplug.factory.guzzle6'
plugins: ['httplug.plugin.redirect', 'httplug.plugin.retry'] |
adding a new test in #118 to prevent the regression you spotted. |
134fc36
to
deb4eb3
Compare
->arrayNode('clients') | ||
->fixXmlConfig('plugin') |
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.
this must go after the ->prototype('array')
array line to apply to the things inside the array and not to the array itself (which has numerical keys)
yay, this seems to actually work out! trying to get the doc started, then lets merge this. |
this is now ready. i quickly tried in a symfony app and it works now fine, including debug toolbar. |
ac21608
to
c6058e8
Compare
I've started tested it a little. Found a unrelated bug... (#121) I'll will try to do a final review tonight if you are happy with the current state of this PR. |
great! yes i am happy with it. squashed the commits and it does look right to me. but am sure there are things to improve and i might have missed something. |
->arrayNode('plugins') | ||
->info('A list of plugin service ids and client specific plugin definitions. The order is important.') | ||
->prototype('array') | ||
; |
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.
You do not call ->end()
here and I know that it is on purpose. You should at least add a comment here. Or event better: Create the plugin node and then add it to the tree. (I think that is possible)
Im happy to merge when all my comments have been addressed or answered. Good job 👍 |
c6058e8
to
80122ec
Compare
80122ec
to
11eeafc
Compare
did some more cleanup based on your feedback, @Nyholm any more suggestions or is this good? |
Im all good. I'm very happy with this PR. It is an amazing improvement. Thank you |
What's in this PR?
Add new configuration for plugins specifically to a client. The global plugin configuration is duplicated to allow configuring all plugins with client specific information.
Why?
See #110
Example Usage
You can specify the httplug.client.{name}.plugin.add_host in the plugins list if you want the host plugin to come somewhere else than last in the chain.
Checklist