Skip to content

[Messenger] make dispatch(), handle() and send() methods return Envelope #28983

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

Merged
merged 1 commit into from
Oct 26, 2018

Conversation

nicolas-grekas
Copy link
Member

@nicolas-grekas nicolas-grekas commented Oct 25, 2018

Q A
Branch? 4.2
Bug fix? no
New feature? yes
BC breaks? no (already broken ;) )
Deprecations? no
Tests pass? yes
Fixed tickets -
License MIT
Doc PR -

Follow up of #28909. We can do better than return void: let's return Envelope!
This means middleware and senders should also return Envelope, so that we can typically read back the stamps that were added during the sending process (eg to get the Kafka queue id).

ping @dunglas as we discussed that first on Slack, and @sroze as we confirmed interest IRL today.

(User handlers don't know anything about envelopes so they still should return void - use senders or middleware if you need to populate/read envelopes.)

@nicolas-grekas nicolas-grekas added this to the 4.2 milestone Oct 25, 2018
@nicolas-grekas nicolas-grekas requested a review from sroze as a code owner October 25, 2018 13:22
@nicolas-grekas nicolas-grekas force-pushed the messenger-return-envelope branch 2 times, most recently from 8677998 to 43ce7dd Compare October 25, 2018 14:17
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.

Yes, much better. That sounds good.

*/
final class Envelope
class Envelope
Copy link
Member

Choose a reason for hiding this comment

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

Why is the reason do remove PHP final here? I understand that the @final is not enforced, probably to allow people to override the class, but then what's the point?

Copy link
Member Author

Choose a reason for hiding this comment

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

The tests require the change for mocks.

Copy link
Member Author

Choose a reason for hiding this comment

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

(In order to mock the new return values.)

Copy link
Contributor

Choose a reason for hiding this comment

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

You could consider to introduce an interface or to just create the Envelope object in tests (instead of mocking it). I don't see it mocked anywhere by the way.

Copy link
Member

Choose a reason for hiding this comment

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

Data object -> no mocks. In any case, removing final "just" for the tests sounds like a terrible idea.

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree with @fabpot that Envelope does not need to be mocked and thus could remain final.

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree with @fabpot too

Copy link
Member Author

Choose a reason for hiding this comment

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

reverted, the class is now really final again

Copy link
Contributor

@Tobion Tobion left a comment

Choose a reason for hiding this comment

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

I like all the recent changes in Messenger.

@nicolas-grekas nicolas-grekas force-pushed the messenger-return-envelope branch from 43ce7dd to fa63e7e Compare October 26, 2018 08:10
@nicolas-grekas nicolas-grekas force-pushed the messenger-return-envelope branch from fa63e7e to 4b0e015 Compare October 26, 2018 08:10
@nicolas-grekas
Copy link
Member Author

PR rebased, ready.

@sroze
Copy link
Contributor

sroze commented Oct 26, 2018

Thank you @nicolas-grekas.

@sroze sroze merged commit 4b0e015 into symfony:master Oct 26, 2018
sroze added a commit that referenced this pull request Oct 26, 2018
…ds return Envelope (nicolas-grekas)

This PR was merged into the 4.2-dev branch.

Discussion
----------

[Messenger] make dispatch(), handle() and send() methods return Envelope

| Q             | A
| ------------- | ---
| Branch?       | 4.2
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no (already broken ;) )
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

Follow up of #28909. We can do better than return `void`: let's return `Envelope`!
This means middleware and senders should also return `Envelope`, so that we can typically read back the stamps that were added during the sending process (eg to get the Kafka queue id).

ping @dunglas as we discussed that first on Slack, and @sroze as we confirmed interest IRL today.

(User handlers don't know anything about envelopes so they still should return `void` - use senders or middleware if you need to populate/read envelopes.)

Commits
-------

4b0e015 [Messenger] make dispatch(), handle() and send() methods return Envelope
@nicolas-grekas nicolas-grekas deleted the messenger-return-envelope branch October 26, 2018 11:11
fabpot added a commit that referenced this pull request Oct 27, 2018
…wareInterface bc-break (skalpa)

This PR was merged into the 4.2-dev branch.

Discussion
----------

[Messenger] Fix DoctrineTransactionMiddleware after MiddlewareInterface bc-break

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

Fixes `DoctrineTransactionMiddleware` that got broken by #28983, and adds tests.

Commits
-------

378ca06 Fix DoctrineTransactionMiddleware after MiddlewareInterface bc-break
This was referenced Nov 3, 2018
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.

8 participants