-
Notifications
You must be signed in to change notification settings - Fork 440
Add autoconfigure for services extending PsrProcess interface #452
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
This would work for processors that implement TopicSubscriber or CommandSubscriber interfaces. It would fail If none of them is implemented cuz in that case a developer should add extra parameters to the tag. Could we do autotag for TopicSubscriber or CommandSubscribe interfaces only? |
Okay I get it. Question is, can anyone use TopicSubscriber or CommandSubscriber without implementing PsrProcessor? I did the test and I can. Maybe what we can do is what you say plus make CommandSubscriber and TopicSubscriber extend from the PsrProcessor interface. Just a suggestion. |
@makasim Have you tought about what I said? If you don't think is a good idea let me know and I can just do what you say. :) |
@mnavarrocarter I dont have any particular reasons against it though I tend to keep it as is. Can we do it later ? |
@makasim Sure we can. I'll work on the autoconfig of the two interfaces you mentioned. Should be ready in a couple of hours. |
Also, just a side note. I tend to squash all my commits before merging, but your merging strategy is "merge commit". If you use "fast-forward" merge you'll get a better history for feature branches that are squashed in a single commit, and you would get rid of those merge commits in the middle. :) |
@mnavarrocarter the auttag feature should be enabled for newer versions of symfony see failed tests https://travis-ci.org/php-enqueue/enqueue-dev/jobs/389233722 |
@makasim Here we go again! |
The last thing. There are code style issues, Could you please fix them https://travis-ci.org/php-enqueue/enqueue-dev/jobs/389255972? |
…or TopicSubscriberInterface This will allow to symfony users that have autowiring/autoconfigure enabled to be able to rapidly create their processors without worrying registering them as a service and adding the tag. This closes php-enqueue#409 and php-enqueue#405. Also, keeps in mind php-enqueue#410. That's why services are public until a better solution is implemented.
I think that we are done here! That PR was tougher than I thought! |
Thanks @mnavarrocarter for this. I tried the PR, but didn't have time (and aren't skilled enough with symfony) to finish it in time. @makasim too. You guys make open source rock! |
Thanks for your kind words @daften Glad to be able to help a bit. Hope this gets released soon! :) |
'transport' => [], | ||
]], $container); | ||
|
||
if (method_exists($container, 'registerForAutoconfiguration')) { |
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.
The test has to be split into two. One test the case where the method is not available and whet it presents
@mnavarrocarter could you please fix the test? I'd be happy to merge this |
@makasim Sure I can. Sorry I've been busy at work. You'll have it fixed later today. :) |
Can we merge here? |
@dkarlovi sure, as soon as the test is fixed. |
fixes #405 |
Hi guys, awesome bundle but due to the autoconfiguration I'm bumping into an issue where the Processor is cached/defined twice and therefore consumes a message twice. My services.yaml has autoconfigure on true, and has defined the processor as: With this, the processor looks like this: use Interop\Queue\PsrContext; use Symfony\Component\DependencyInjection\ContainerAwareInterface; class ImportCountProcessor implements PsrProcessor, TopicSubscriberInterface, ContainerAwareInterface
} Any ideas on how I can fix the duplication of the processor? Do I just need to remove the import_count_processor definition? [edited for code markup] |
set |
Okido thanks for the quick reply, removing the tag from services.yaml fixed my issue |
This will allow to Symfony users that have autoconfigure/autowiring enabled to avoid defining
explicitly the processor service and its tag. Now, the symfony container does it automatically.