Configure grain state serializer per storage provider #6936
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Right now, for the Azure providers at least, it's not possible to use a custom serializer: you only have the choice between Newtonsoft.Json or the Orleans
SerializationManager
.Users can configure the
SerializationManager
to use a custom serializer for certains types, but this method has two main limitations:SerializationManager
.This PR enable configuration of custom serializer for grain state per storage provider.
The base interface for these serializer is
IGrainStorageSerializer
. In this PR I included 3 implementations:JsonGrainStorageSerializer
: an implementation that uses Newtonsoft.JsonOrleansGrainStorageSerializer
: an implementation that uses the OrleansSerializationManager
GrainStorageSerializer
: an implementation that use a primary Serializer, but capable of deserialize multiple formats.The idea of this interface is that it's easy to compose. The
Serialize
method will return atag
, that will be used to identify the type of the serializer when callingDeserialize
.It should be easy to add custom implementation that read from a config, or from class Attributes for example.
Here is the new way to configure the Azure table storage provider:
For now, old configuration method are still available, and the
GrainStorageSerializer
will be used by default. I think for 4.0 we should remove this and ask the user to configure explicitely a serializer.The configuration may seems more complicated, but maybe we can add some configuration helper methods like that:
for serialization implementation that requires none or few configuration steps.