Skip to content

Conversation

Tobion
Copy link
Contributor

@Tobion 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

@sroze
Copy link
Contributor

sroze commented Apr 22, 2018

What's the use-case for such change?

@Tobion
Copy link
Contributor Author

Tobion commented Apr 22, 2018

Actually I think returning several senders does not make sense. It should be public function getSenderForMessage($message): ?SenderInterface; If multiple senders are wanted, just return a ChainSender implementation. And the forwardToSenderAndHandler logic should not depend on some arbitrary null value that violates the interface anyway. It could just be a marker interface implemented by the sender. Or an additional method in the SenderInterface like forwardToHandler: bool

@sroze
Copy link
Contributor

sroze commented Apr 22, 2018

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 ChainSender but I don't really get the "marker interface implemented by the sender". What do you mean? How would you configure this on the framework.messenger configuration?

@Tobion
Copy link
Contributor Author

Tobion commented Apr 25, 2018

Something like where handle defaults to false.

framework:
    messenger:
        routing:
            'My\Message\ToBeSentToTwoSenders': 
                senders: [amqp, audit]
                handle: bool

sroze
sroze previously approved these changes Apr 27, 2018
@nicolas-grekas
Copy link
Member

So, shouldn't we change the interface as @Tobion suggests, allowing only one sender?
The configuration can be kept the same, creating a chained sender when needed.

@sroze
Copy link
Contributor

sroze commented Apr 30, 2018

@Tobion are you willing to make this change? I'd definitly approve it.

@Tobion
Copy link
Contributor Author

Tobion commented Apr 30, 2018

I try to get to it tomorrow

@sroze sroze dismissed their stale review May 3, 2018 13:14

Needs work

@sroze
Copy link
Contributor

sroze commented May 3, 2018

Status: Needs work

@Tobion Tobion force-pushed the support-iterable-messenger-sender-locator branch from f24671e to 3935548 Compare May 6, 2018 20:03
@Tobion Tobion changed the title [Messenger] support iterable in sender locator [Messenger] implement several senders using a ChainSender May 6, 2018
@Tobion
Copy link
Contributor Author

Tobion commented May 6, 2018

I implemented the single sender using a ChainSender approach.

@Tobion Tobion force-pushed the support-iterable-messenger-sender-locator branch from 3935548 to 3d0eb0a Compare May 7, 2018 09:05
@ogizanagi ogizanagi force-pushed the support-iterable-messenger-sender-locator branch 2 times, most recently from b8316cf to dc9bc95 Compare May 7, 2018 14:08
Copy link
Contributor

@ogizanagi ogizanagi left a 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;
Copy link
Contributor

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)?

Copy link
Contributor Author

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.

@Tobion Tobion force-pushed the support-iterable-messenger-sender-locator branch 3 times, most recently from a0653d1 to 0d430b8 Compare May 8, 2018 14:58
Copy link
Contributor

@sroze sroze left a 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)
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Contributor

@sroze sroze left a 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.

@Tobion Tobion force-pushed the support-iterable-messenger-sender-locator branch from 0d430b8 to a1d2dfe Compare May 9, 2018 12:00
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'])) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

\count

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@Tobion Tobion force-pushed the support-iterable-messenger-sender-locator branch from a1d2dfe to 1966cd7 Compare May 9, 2018 16:21
@sroze
Copy link
Contributor

sroze commented May 9, 2018

@Tobion, unfortunately, you are going to have to rebase. Last step 🤞

@Tobion Tobion force-pushed the support-iterable-messenger-sender-locator branch 2 times, most recently from 78b1b71 to ddc0c3b Compare May 11, 2018 13:00
@Tobion Tobion force-pushed the support-iterable-messenger-sender-locator branch from ddc0c3b to 198925e Compare May 16, 2018 13:12
/**
* @internal
*/
public static function getValueFromMessageRouting(array $mapping, $message)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

: ?array at end?

Copy link
Contributor Author

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.

Copy link
Member

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?

Copy link
Contributor

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 strings and bools. (it does not return an array anymore, that's the point of this PR :))

/**
* @internal
*/
public static function getValueFromMessageRouting(array $mapping, $message)
Copy link
Contributor

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 strings and bools. (it does not return an array anymore, that's the point of this PR :))

@sroze
Copy link
Contributor

sroze commented May 17, 2018

Thank you @Tobion.

@sroze sroze merged commit 198925e into symfony:4.1 May 17, 2018
sroze added a commit that referenced this pull request May 17, 2018
…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
@Tobion Tobion deleted the support-iterable-messenger-sender-locator branch May 17, 2018 09:34
javiereguiluz added a commit to symfony/symfony-docs that referenced this pull request Oct 12, 2018
… (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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants