Message nesting

41 views
Skip to first unread message

Tobias Krueger

unread,
May 9, 2023, 4:29:45 AM5/9/23
to grpc.io
Hi everyone,
the recommended way to define messages for a RPC call is to append "Request" and "Response" to the name of the Rpc.

A colleague proposed an alternative solution by using nested messages instead.

So he proposed to use the following structure

service Service {
  rpc Foo(Foo.Request) returns (Foo.Response) {}
}

message Foo {
     enum {
        // enum declarations
     }
     message Request {
        // Parameters
     }
     message Response {
     }
}

IMHO a clever solution where the enum declarations are local to the call as well..

Any reasons NOT to use this structure?

Thanks for your feedback
Tobias
Reply all
Reply to author
Forward
0 new messages