Search code examples
javaspringmicroservicesprotocol-buffersgrpc

Is there a way to pass type arguments in message variable in protobuf file?


Is there a way to pass type arguments in response message of protobuf file?

For example, I have a response type of SResponse<E> with uses generic argument and I want to do same in my protobuf file.

I have tried searching on web nothing specific is mentioned in docs.


Solution

  • No.

    Different values of E must be represented by different protobuf messages.

    You will want to:

    • Either cast your generic types to a single protobuf message
    • Or define a protobuf message per value of E