Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Messenger] Envelope as first class citizen in middleware too#27322

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
ogizanagi wants to merge2 commits intosymfony:masterfromogizanagi:messenger/middleware_envelope
Closed

[Messenger] Envelope as first class citizen in middleware too#27322

ogizanagi wants to merge2 commits intosymfony:masterfromogizanagi:messenger/middleware_envelope

Conversation

@ogizanagi
Copy link
Contributor

@ogizanagiogizanagi commentedMay 20, 2018
edited
Loading

QA
Branch?4.2
Bug fix?no
New feature?no
BC breaks?yes
Deprecations?no
Tests pass?yes
Fixed ticketsN/A
LicenseMIT
Doc PRN/A

Nothing really new here, as I already suggested doing so in the original PR introducing theEnvelope object, but we wanted first to give a try about keeping the ability to just get the message in middleware.

Now, I'm still convinced making the Envelope a first-class citizen for everything inside the bus would homogenize and simplify things for everyone and is a better design than theEnvelopeAwareInterface, while keeping the message at both ends of the bus (i.e:MessageBusInterface::dispatch and handlers).

Cons:

  • Not what command buses' users are already used to
  • Requires an extra call to$envelope->getMessage() in a middleware not using theEnvelope
  • Envelope seems not really relevant in some parts of a CQRS / layered architecture app (...or is it?)

Pros:

  • Homogeneous use of theEnvelope anywhere inside the bus
  • Strict & faithfulMiddlewareInterface::handle(Envelope $envelope) typehint.
    Not cheating with the non-restrictiveobject typehint which was never intended for this feature.
  • No moreEnvelopeAwareInterface as there is no more core usage
  • No more manipulation regarding the next message or envelope consumer:
    e.g:

My opinion is the naming and the concepts introduced by theEnvelope VO are small and abstract (envelope, message, items) enough to even fit in the CQRS world or in a middleware in myApplication namespace (when such a middleware is relevant).


img_0835
(cheers from Spain)

yceruto, hhamon, and andersonamuller reacted with thumbs up emoji
Copy link
Member

@ycerutoyceruto left a comment

Choose a reason for hiding this comment

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

This looks better to me, thank you!

publicfunctiontestItAlsoCallsTheNextMiddlewareBasedOnTheMessageClass()
{
$message =newDummyMessage('Hey');
$envelope =Envelope::wrap(newDummyMessage('Hey'));
Copy link
Member

Choose a reason for hiding this comment

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

It feels likenew Envelope(...) makes more sense here if you're sure that the message isn't another envelope instance, it also seems natural to me, IMHO. (same for other tests)

Copy link
ContributorAuthor

@ogizanagiogizanagiMay 20, 2018
edited
Loading

Choose a reason for hiding this comment

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

You're right. I think I'll remove this named construct as well as it doesn't really serve a purpose anymore, appart the fluent api without extra()

@srozesroze modified the milestones:4.1,nextMay 21, 2018
@sroze
Copy link
Contributor

Let's move this to 4.2; time for 4.1-beta2 :)

@hhamon
Copy link
Contributor

Postponing to 4.2 means having a BC break.

@jvasseur
Copy link
Contributor

@hhamon BC breaks are OK since the component is experimental

@ogizanagi
Copy link
ContributorAuthor

ogizanagi commentedMay 21, 2018
edited
Loading

Right, I’ve added the BC break label already. I should have submitted this sooner, my bad. The component is experimental so we could just document the upgrade path in 4.2 but I agree this is far from being ideal to require such a change for end-users and lib maintainers.
I already agreed with@sroze to move it to 4.2. There is only a few time before 4.1 release and if this is not part of beta2 we can’t make it.However if we don’t want this now, will it ever happen anyway? Definitively time for 4.1-beta2. This'll wait 4.2.

@nicolas-grekasnicolas-grekas changed the base branch from4.1 tomasterJune 19, 2018 13:19
@sroze
Copy link
Contributor

I still believe that adding this is wrong: in many cases that I have, I don't care about theEnvelope, just the message; and in this specific case, I don't see why I should care about it. Also, having theEnvelope exposes to potential confusion like highlighted in the documentation PR: "So should I do$envelope->get(MyMessage::class) or$envelope->getMessage()?". Such complexity should be hidden from the end-user. Dealing with the Envelope is something "advanced" than developers should not have to care about at first glance IMHO.

jvasseur and Nyholm reacted with thumbs up emoji

@ogizanagi
Copy link
ContributorAuthor

ogizanagi commentedJun 30, 2018
edited
Loading

If that's the only fear you have about this, I'd suggest to add an abstractMiddleware class which would just ask users to implement ahandleMessage(object $message, callable $next) method instead (in the same spirit of the abstractVoter class hiding some complexity from end-users).
To me, comments & facts like insymfony/symfony-docs#9757 (comment) hint this design is a bit flawed this way.
Code removal in this PR is another hint.

@sroze
Copy link
Contributor

Following#27841 being merged, I'm closing this one :)

yceruto and ogizanagi reacted with confused emoji

@srozesroze closed thisJul 20, 2018
@ogizanagi
Copy link
ContributorAuthor

#27841 being merged does not change anything regarding this PR actually.
But we've already expressed each other our arguments multiple times. I would have expected to get more insights from the community after using the component and this specific feature (still too soon?), this PR allowing discussions. So, your call. 🤷‍♂️

sroze added a commit that referenced this pull requestOct 21, 2018
…leware handlers (nicolas-grekas)This PR was merged into the 4.2-dev branch.Discussion----------[Messenger] make Envelope first class citizen for middleware handlers| Q             | A| ------------- | ---| Branch?       | 4.2| Bug fix?      | no| New feature?  | no| BC breaks?    | yes| Deprecations? | no| Tests pass?   | yes| Fixed tickets | -| License       | MIT| Doc PR        | -This PR sits on top of#28909 so that only the 2nd commit should be reviewed for now, until I rebase it.This idea has already been proposed and rejected in#27322.Yet, now that I've reviewed in depth the component, I politely but strongly suggest to reconsider.Middleware handlers are the central piece of the routing layer.When `dispatch()` accepts `object|Envelope`, it's because it sits on the outer boundary of the component. `handle()` on the contrary plugs inside its core routing logic, so that it's very legitimate to require them to deal with `Envelope` objects. Yes, some middleware care only about the message inside. That's fine calling `getMessage()` for them.Right now, we built a complex magic layer that acts as a band-aid *just* to save this call to `getMessage()`. For middleware that want the envelope, we require an additional interface that magically *changes* the expected argument. That's very fragile design: it breaks the `L` in `SOLID`...Looking at the diff stat, this is most natural.Commits-------ae46a43 [Messenger] make Envelope first class citizen for middleware handlers
@ogizanagiogizanagi deleted the messenger/middleware_envelope branchOctober 31, 2018 17:40
@nicolas-grekasnicolas-grekas modified the milestones:next,4.2Nov 1, 2018
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@ycerutoycerutoyceruto left review comments

@srozesrozeAwaiting requested review from sroze

Assignees

No one assigned

Projects

None yet

Milestone

4.2

Development

Successfully merging this pull request may close these issues.

7 participants

@ogizanagi@sroze@hhamon@jvasseur@yceruto@nicolas-grekas@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp