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

Make sure to read the last snapshot and fix deserializing data #91

Merged

Conversation

philipgiuliani
Copy link
Contributor

@philipgiuliani philipgiuliani commented Feb 16, 2024

Issue 1: Even though the combination of start and backwards seems to make sense, this implementation was not correct. The EventStore returns the first snapshot in this case instead of the last snapshot. Unfortunately this doesn't seem to be covered by the Commanded Testsuite.

Issue 2: The snapshot.data was not decoded to a struct but just to a map, which caused the ProcessManager to not match any of the handle clauses.

@@ -140,7 +140,8 @@ defmodule Commanded.EventStore.Adapters.Spear.Mapper do
|> Spear.Event.to_proposed_message(%{serializer_content_type => &serializer.serialize/1})
end

def to_snapshot_data(%RecordedEvent{data: %SnapshotData{} = snapshot} = event) do
def to_snapshot_data(%RecordedEvent{data: %SnapshotData{} = snapshot} = event)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

When using the JSON instead of the TermSerializer the snapshot.data isn't a struct yet and we need to proceed to the next case which uses the JsonDecoder.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Without this fix the snapshot.data remains just a map.

@philipgiuliani philipgiuliani changed the title Make sure to read the last snapshot Make sure to read the last snapshot and fix deserializing data Feb 16, 2024
@fabriziosestito fabriziosestito self-requested a review February 20, 2024 15:28
Copy link
Owner

@fabriziosestito fabriziosestito left a comment

Choose a reason for hiding this comment

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

Sorry for the late merge, busy times!

@fabriziosestito fabriziosestito merged commit e685f51 into fabriziosestito:main Feb 20, 2024
2 checks passed
@philipgiuliani
Copy link
Contributor Author

No problem, thanks for taking a look! ☺️

@philipgiuliani philipgiuliani deleted the fix_read_snapshot branch February 20, 2024 15:49
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.

2 participants