-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Messenger] Add option allow_no_senders
to enable throwing when a message doesn't have a sender
#46053
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
[Messenger] Add option allow_no_senders
to enable throwing when a message doesn't have a sender
#46053
Conversation
src/Symfony/Component/Messenger/Middleware/SendMessageMiddleware.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Messenger/Middleware/SendMessageMiddleware.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Messenger/Middleware/SendMessageMiddleware.php
Outdated
Show resolved
Hide resolved
src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd
Outdated
Show resolved
Hide resolved
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 conclude our discussion about naming. Here is my view.
src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Messenger/Middleware/SendMessageMiddleware.php
Outdated
Show resolved
Hide resolved
@@ -1515,7 +1515,7 @@ function ($a) { | |||
->addDefaultsIfNotSet() | |||
->children() | |||
->enumNode('default_middleware') | |||
->values([true, false, 'allow_no_handlers']) | |||
->values([true, false, 'allow_no_handlers', 'throw_no_routing']) |
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 not adding as a proper boolean node under buses
, since these values are mutually exclusive?
That would allow the option to also be used as arg when using the SendMessageMiddleware
without the defaults.
allow_no_senders
to enable throwing when a message doesn't have a sender
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 updated the PR title with what looks best to me. Please upgrade the line in the changelog if you're OK with it.
@@ -1521,7 +1521,7 @@ function ($a) { | |||
->addDefaultsIfNotSet() | |||
->children() | |||
->enumNode('default_middleware') | |||
->values([true, false, 'allow_no_handlers']) | |||
->values([true, false, 'allow_no_handlers', 'allow_no_senders']) |
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.
Following the comment from @HeahDude, I think it would be nice to turn this default_middleware option into an array node:
->arrayNode('default_middleware')
->canBeDisabled()
->children()
->booleanNode('allow_no_handlers')->defaultFalse()->end()
->booleanNode('allow_no_senders')->defaultTrue()->end()
With an appropriate beforeNormalization()
closure to turn the old configs into the new one.
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.
But then there would be conflict between allow_no_handlers
and enabled: true
that would need proper handling.
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.
which conflict? "enabled" would be about "default_middleware", not about allow_no_handlers
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 mean, in your example, using allow_no_handlers
requires default_middleware
to be enabled: false
, hence the current enum as they are mutually exclusive.
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.
it requires enable: true
yes. enabled/disabled applies to a whole subnode, there's nothing specific to this node here. If you define this, then of course allow_no_handlers
is going to be ignored:
default_middleware:
enable: false
allow_no_handlers: true
src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php
Show resolved
Hide resolved
src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd
Show resolved
Hide resolved
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.
Just minor things, but LGTM thanks.
src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Messenger/Middleware/SendMessageMiddleware.php
Outdated
Show resolved
Hide resolved
Do we want to set it to |
…essage doesn't have a sender
Thank you @babeuloula. |
…rs` (babeuloula) This PR was merged into the 6.2 branch. Discussion ---------- [Messenger] Add documentation for `allow_no_senders` Hello, There is the documentation for my PR symfony/symfony#46053. Fix symfony#17378 Have a nice day. Commits ------- 4d7398f symfony#17378: Add documentation for allow_no_senders
Hello,
For my first contribution to the Symfony community I would like to propose this feature.
On my projects, sometimes I forget to update the messenger.yaml file and I don't have a routing for my new message. If you don't set the entry on the
routing
section, the message will be dispatch like if you use sync://.In order to don't forget to add the entry, I've update the
SendMessageMiddleware
middleware to throw an exception.For the documentation, I never work with rst file, so if someone would help me, i will very appreciate.
Thanks.