Skip to content
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

Improve CQS System #53

Merged
merged 1 commit into from
Dec 27, 2023
Merged

Improve CQS System #53

merged 1 commit into from
Dec 27, 2023

Conversation

yceruto
Copy link
Contributor

@yceruto yceruto commented Dec 27, 2023

This proposal contains several improvements:

  • Using generic templates in Command/Query classes, so documenting the returned type for each dispatch/ask invocation is no longer necessary.
  • Now FindBookQuery strictly returns a Book instance; otherwise, a MissingBookException is thrown.
  • The MissingBookException is mapped to return a 404 status code, so a clear exception message is now displayed.
  • Replace CommandHandlerInterface with the AsCommandHandler attribute, and QueryHandlerInterface with the AsQueryHandler attribute. The reason behind this is the fact that these interfaces have no contract; they are used as metadata to configure the messenger handler only. So, in this case, we can now use attributes instead as they are intended for that purpose.

Copy link
Owner

@mtarld mtarld left a comment

Choose a reason for hiding this comment

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

Thank you, @yceruto, that's a great code simplification 🙂

@mtarld mtarld merged commit e3a90e1 into mtarld:main Dec 27, 2023
5 checks passed
@chalasr
Copy link
Collaborator

chalasr commented Dec 27, 2023

Thanks Yonel!

@yceruto yceruto deleted the cqs_improvements branch December 27, 2023 16:08
@yceruto
Copy link
Contributor Author

yceruto commented Dec 27, 2023

Thank you guys for this demo!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants