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

Change PersistenceMessageSerializer base class to SerializerWithStringManifest #5002

Open
wants to merge 12 commits into
base: dev
Choose a base branch
from

Conversation

Arkatufus
Copy link
Contributor

Closes #5001

// use reflection to create the generic type of PersistentFSM.PersistentFSMSnapshot
Type[] types = { typeof(string), type.GenericTypeArguments[0], typeof(TimeSpan?) };
object[] arguments = { message.StateIdentifier, GetPayload(message.Data), timeout };
Type[] types = { typeof(string), payload.GetType(), typeof(TimeSpan?) };
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Get the type of the payload from the payload type instead of relying on a generic passed into the method

Copy link
Member

@Aaronontheweb Aaronontheweb left a comment

Choose a reason for hiding this comment

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

Minor backwards compat changes requested

&& type.GetGenericTypeDefinition() == typeof(PersistentFSM.PersistentFSMSnapshot<>)) return GetPersistentFSMSnapshot(type, bytes);
switch (manifest)
{
case null:
Copy link
Member

Choose a reason for hiding this comment

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

good catch on the null

{
return shortened;
}

shortened = cleanAssemblyVersionRegex.Replace(type.AssemblyQualifiedName, string.Empty);
// Defensive coding. `type.AssemblyQualifiedName` can return null if type is of generic type parameter type
Copy link
Member

Choose a reason for hiding this comment

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

LGTM

throw new SerializationException($"Unimplemented deserialization of message with manifest [{manifest}] in [{GetType()}]");
}

public override string Manifest(object obj)
Copy link
Member

Choose a reason for hiding this comment

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

For the time being, we should return the legacy types - I believe there are some persistence plugins (i.e. SQL ones) that are still relying on manifest data using reflection and while I would like to eventually clean that up, probably best to change as little as possible here first.

case PersistentFSM.StateChangeEvent _:
return StateChangeEventManifest;
return obj.GetType().TypeQualifiedName();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Would something like this be OK?

Copy link
Member

Choose a reason for hiding this comment

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

Just use the hard-coded constants

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'd have problem with Akka.Persistence.Fsm.PersistentFSM.PersistentFSMSnapshot because it is a generic class, hard coding would not work

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.

Need to make PersistenceMessageSerializer version tolerant
2 participants