-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
[Messenger] implement several senders using a ChainSender #27002
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] implement several senders using a ChainSender #27002
Conversation
Tobion
commented
Apr 21, 2018
Q | A |
---|---|
Branch? | master |
Bug fix? | no |
New feature? | yes |
BC breaks? | no |
Deprecations? | no |
Tests pass? | yes |
Fixed tickets | |
License | MIT |
Doc PR |
What's the use-case for such change? |
Actually I think returning several senders does not make sense. It should be |
I appreciate and agree that this isn't the "cleanest" solution but it has the benefit of being simple and working well 🙃I see the point of the |
Something like where handle defaults to false.
|
So, shouldn't we change the interface as @Tobion suggests, allowing only one sender? |
@Tobion are you willing to make this change? I'd definitly approve it. |
I try to get to it tomorrow |
Status: Needs work |
f24671e
to
3935548
Compare
I implemented the single sender using a ChainSender approach. |
3935548
to
3d0eb0a
Compare
b8316cf
to
dc9bc95
Compare
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've rebased it after the merge of #26945
* | ||
* @return bool | ||
*/ | ||
public function forwardToSenderAndHandler($message): bool; |
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.
Isn't this method name a bit misleading? I didn't expected it to be as "isser" at first, but something performing an action.
Shouldn't it be something like mustForwardToSenderAndHandler
(or better)?
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.
Yeah makes sense to change it.
a0653d1
to
0d430b8
Compare
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.
Except the SenderInterface
changed, I'm 👍
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function send($message) |
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 now has the : void
typehint, to be changed.
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.
done
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.
Adding the "Request changes" review explicitly until the SenderInterface contract is changed.
0d430b8
to
a1d2dfe
Compare
foreach ($config['routing'] as $message => $messageConfiguration) { | ||
if ('*' !== $message && !class_exists($message) && !interface_exists($message, false)) { | ||
throw new LogicException(sprintf('Messenger routing configuration contains a mistake: message "%s" does not exist. It needs to match an existing class or interface.', $message)); | ||
} | ||
|
||
$messageToSenderIdsMapping[$message] = $messageConfiguration['senders']; | ||
if (1 < count($messageConfiguration['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.
\count
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.
done
a1d2dfe
to
1966cd7
Compare
@Tobion, unfortunately, you are going to have to rebase. Last step 🤞 |
78b1b71
to
ddc0c3b
Compare
ddc0c3b
to
198925e
Compare
/** | ||
* @internal | ||
*/ | ||
public static function getValueFromMessageRouting(array $mapping, $message) |
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.
: ?array
at end?
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.
that would not be correct. we cant typehint it.
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 meant the return typehint, we can't?
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 that function is used for two use cases: return string
s and bool
s. (it does not return an array anymore, that's the point of this PR :))
/** | ||
* @internal | ||
*/ | ||
public static function getValueFromMessageRouting(array $mapping, $message) |
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 that function is used for two use cases: return string
s and bool
s. (it does not return an array anymore, that's the point of this PR :))
Thank you @Tobion. |
…r (Tobion) This PR was merged into the 4.1 branch. Discussion ---------- [Messenger] implement several senders using a ChainSender | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no <!-- don't forget to update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tests pass? | yes <!-- please add some, will be required by reviewers --> | Fixed tickets | | License | MIT | Doc PR | Commits ------- 198925e [Messenger] implement several senders using a ChainSender
… (ogizanagi) This PR was merged into the 4.1 branch. Discussion ---------- [Messenger] Fix messenger.routing send_and_handle config Ref: symfony/symfony#27002 Credits to @xabbuh who found this doc was outdated. Commits ------- 9b91634 [Messenger] Fix messenger.routing send_and_handle config