-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Configure grain state serializer per storage provider #6936
Configure grain state serializer per storage provider #6936
Conversation
When is this expeced to merge? I think the ADO.NET ones should be brought on par (Azure and otherwise) and maybe at least I should use a bit of time to understand what ought to be changed. The following is a short background for questions in the end. It looks to me this affects at least how a (de)serializer is configured. It is not clear to me how this affects how during running the application the IGrainStorage implementation is affected. It looks to me, I am not sure, this affects the configuration and what and how configuration is provided to the The reason I think this is that currently in ADO.NET allows one to choose dynamically from the provided (de)serializers with several parameters such as grain type, persisted data type and even payload if needed. The interface is at https://github.com/dotnet/orleans/blob/master/src/AdoNet/Orleans.Persistence.AdoNet/Storage/Provider/IStorageSerializationPicker.cs#L81. In practice this is fixed to JSON, XML or binary during configuration as passing this selector implementation from options to the ADO.NET In effect I am asking if it is possible now and should we coordinate on the interface to achieve the following:
I would like to remove references to specific sets of (de)serializer libraries and this selector function load whatever the user likes to use. So basically in the options would look like having a selector function and a matching (de)serializer implementation. By default a convenience method could be used that implements JSON, XML and binary as is done currently. Maybe the convenience functions could look like in "Azure implementation". I appreciate decoupling the selector function for (de)serializer may not be the goal on these loaders, but I am also thinking that if it very "easily doable", maybe it's possible to coordinate a bit here with interfaces. |
Not in a rush, but it should be in for 4.0
Yes! That's the plan.
Ideally, it should be doable with a custom implementation of From Ideally, I think Let's sync on gitter or Teams to address your concern :) |
4455a33
to
c535e59
Compare
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.