Skip to content

[Messenger] Deprecate HandleTrait in favor of a new SingleHandlingTrait #52952

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

Closed
wants to merge 1 commit into from

Conversation

MatTheCat
Copy link
Contributor

@MatTheCat MatTheCat commented Dec 8, 2023

Q A
Branch? 7.1
Bug fix? no
New feature? yes
Deprecations? yes
Issues Fix #52300
License MIT

In competition with #52949

When using the HandleTrait, the HandlerFailedException just adds noise as the wrapped exception is the one we would expect to be thrown.

This PR aims to replace the HandleTrait by a new SingleHandlingTrait, the latter throwing any single exception wrapped in a HandlerFailedException. In addition, it checks for a single handler even if one failed.

@carsonbot carsonbot added this to the 7.1 milestone Dec 8, 2023
@MatTheCat MatTheCat force-pushed the single_handling_trait branch from ff7e5f4 to 574c4ea Compare December 8, 2023 19:27
@MatTheCat MatTheCat changed the title [Messenger] Deprecate HandleTrait in favor of the new SingleHandlingTrait [Messenger] Deprecate HandleTrait in favor of a new SingleHandlingTrait Dec 8, 2023
@MatTheCat MatTheCat force-pushed the single_handling_trait branch 5 times, most recently from b587f76 to 48a75e3 Compare December 9, 2023 11:18
/**
* Dispatches the given message, expecting to be handled by a single handler
* and returns the result from the handler returned value.
* This behavior is useful for both synchronous command & query buses,
Copy link
Contributor

@ro0NL ro0NL Dec 11, 2023

Choose a reason for hiding this comment

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

fact is we're querying for a value, hence i prefer naming QueryBusTrait::query, but not a blocker :)

Copy link
Contributor Author

@MatTheCat MatTheCat Dec 21, 2023

Choose a reason for hiding this comment

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

I don’t want this trait’s name to imply a single use-case as there can be many (a command bus returning IDs e.g.).

EDIT: heh, just found #29167 (comment) 😁

@MatTheCat MatTheCat force-pushed the single_handling_trait branch from 48a75e3 to c19ecda Compare December 11, 2023 17:34
@MatTheCat MatTheCat force-pushed the single_handling_trait branch from c19ecda to da5c907 Compare December 21, 2023 13:55
@chalasr
Copy link
Member

chalasr commented Dec 21, 2023

The value brought by this change doesn't seem worth the cost of deprecating HandleTrait entirely to me. Also the name SingleHandlingTrait doesn't convey the fact it's about synchronous handling.
All in all, I feel like this is not the right approach to solve the issue at hand - IMHO either we address it in HandleTrait with BC preserved or we need to look at the middleware alternative instead

@MatTheCat
Copy link
Contributor Author

Changing for a more explicit name and handling exceptions correctly felt enough for me, but will close then.

@MatTheCat MatTheCat closed this Feb 2, 2024
@MatTheCat MatTheCat deleted the single_handling_trait branch February 2, 2024 18:34
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.

[Messenger] Make HandleTrait unwrap HandlerFailedException
4 participants