-
-
Notifications
You must be signed in to change notification settings - Fork 114
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
Question: Possibilities of usage grpc Reflection with custom Marshallers #320
Comments
That factory is going to push everything to be serialized as JSON (from the blind "=> true")... but the gRPC discovery API isn't expecting JSON, it is expecting protobuf So: take this back a level - what are you trying to achieve with the JSON step? what is is that you are trying to serialize as JSON, and when? |
I need to have json marshaller factory for backward compatibility, unfortunatelly. So, now I have just only an idea to check if incoming message is a valid json and use JsonConverter for valid cases and ProtobufMarshallerFactory.Default.Deserialize via reflection for other cases... |
Backward compatibility with what? Because as it stands: you're serializing everything as JSON, so: that'll break things that aren't expecting JSON. Perhaps use an attribute or marker interface to indicate types that you want to use JSON for. Alternatively, if you make sure that the JSON version is last (rather than first) |
I have some services communicated via gRPC. Some of them were written not by me and they need to pass json between calling and caller methods. |
Mark, I'll resume this discussion, because I found usage case for json marshaller. Let's look at this example:
This is primitive realization for polymorphic contracts. Because I got all time this error:
|
I'm not sure I understand... is the point here that you want to use JSON? If so, I can show you how to attach a JSON serializer at the top level. I'm not sure what this example is meant to be showing me, to be honest. What is the expected outcome here? |
Marc, I just want to say that it will be great to have an ability to create factory classes derived from your ProtobufMarshallerFactory (currently it's not possible) and customize serialization logic. For example, on incoming json messages I want to use JsonSerializer (because, for example, I can have polymorphic contract DTOs), and Protobuf serializer otherwise. |
Hello.
I'm trying to add reflection (for method discovering). I use my own JsonMarshaller (simple, stupid - yes) like this:
but I have problems with discovering through passing cli commands like this:
dotnet grpc-cli ls https://localhost:5001
Here I have an exception in
Deserialize
method.So, is it possible to use Reflection discovery with custom json marshaller?
Thank you.
The text was updated successfully, but these errors were encountered: