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

Add new generic on PgStore and converter trait to decouple persistence from Aggregate::Event #191

Merged
merged 17 commits into from
Apr 3, 2024

Conversation

Johnabell
Copy link
Contributor

@Johnabell Johnabell commented Mar 23, 2024

This PR adds a way to decouple the persistence from the domain Aggregate::Event types.

This removes the need to Aggregate::Event to implement the Event trait to work with PgStore.

It simultaneously provides a way to deprecate events without the effects propagating through a code base. Furthermore it provides an alternative way to upcast events.

I have added an example to demonstrate the use case of deprecation and upcasting.

@Johnabell Johnabell self-assigned this Mar 23, 2024
@Johnabell Johnabell force-pushed the decouple-persistence branch from 9ebfc46 to ff9bac4 Compare March 23, 2024 01:40
@Johnabell Johnabell force-pushed the decouple-persistence branch from ff9bac4 to 25d3329 Compare March 23, 2024 01:46
@Johnabell Johnabell force-pushed the decouple-persistence branch from 0f21d16 to dea2073 Compare March 24, 2024 22:20
@Johnabell Johnabell force-pushed the decouple-persistence branch 2 times, most recently from 8fb9d09 to 7f55781 Compare March 25, 2024 21:41
@Johnabell Johnabell force-pushed the decouple-persistence branch from 7f55781 to 0bef40c Compare March 25, 2024 21:48
@Johnabell Johnabell marked this pull request as ready for review March 26, 2024 16:12
@Johnabell Johnabell requested a review from a team as a code owner March 26, 2024 16:12
Copy link
Contributor

@cottinisimone cottinisimone 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 for this PR. Very nice solution and top for the non-breaking change!

Only some notes (collected together in the meet) regarding some changes that would be worth it doing in this PR:

  • Split schema example into multiple examples, trying to let examples as easy as possible.
  • Update readme with a section like "Decoupe Aggregate Event from DB Event (Schema)"
  • Rename Event trait to be a bit more consistent to its role.
  • Rename some generics to be a one-letter-only generic?

@Johnabell Johnabell force-pushed the decouple-persistence branch from 15bf67c to e75ac61 Compare March 27, 2024 18:34
@Johnabell Johnabell force-pushed the decouple-persistence branch 8 times, most recently from 7c653e9 to 0dcb1db Compare March 27, 2024 19:36
@Johnabell Johnabell force-pushed the decouple-persistence branch 6 times, most recently from bd186b7 to 1841719 Compare March 27, 2024 20:37
@Johnabell Johnabell force-pushed the decouple-persistence branch from 1841719 to 4a9077b Compare March 27, 2024 20:52
@@ -1 +1 @@
msrv = "1.58.0"
msrv = "1.74.0"
Copy link
Contributor Author

@Johnabell Johnabell Mar 27, 2024

Choose a reason for hiding this comment

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

The project currently does not compile with version 1.73.0. We can fix the issue in the crate itself, but it looks like sqlx-core-0.7.4 does not compile with 1.73.0 either. If we wanted to address this we might need to use an older version.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's fine to set 1.74 as minimum version

@Johnabell Johnabell requested a review from cottinisimone March 27, 2024 21:11
@Johnabell Johnabell force-pushed the decouple-persistence branch 2 times, most recently from 7463ffe to 95396c6 Compare March 28, 2024 12:41
@Johnabell Johnabell force-pushed the decouple-persistence branch from 95396c6 to 0b165f8 Compare March 28, 2024 12:48
cottinisimone
cottinisimone previously approved these changes Mar 29, 2024
@Johnabell Johnabell force-pushed the decouple-persistence branch from 769d131 to 69ef2d3 Compare April 2, 2024 10:57
@Johnabell Johnabell requested a review from cottinisimone April 3, 2024 13:40
@Johnabell Johnabell merged commit 8766a1c into master Apr 3, 2024
7 checks passed
@Johnabell Johnabell deleted the decouple-persistence branch April 3, 2024 14:23
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