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
Naming convention for function names doesn't make sense #117
Comments
I've forwarded your question to the folks on my team who are working on new style guidelines to get their input on your request. |
Hello @Sereger13, Actually, we recommend that you create a unique request and response proto for each RPC method. Discovering later on that you need to diverge the top-level request or response can be prohibitively expensive. This includes "empty" responses -- create a unique empty response proto rather than reusing the well-known Empty message type. To achieve reuse -- create shared "domain" message types that can be included in multple Request and Response protos. Your application logic can be written in terms of those types rather than the request and response types. This gives you the flexibility to evolve your method request/response types independently, but share code for logical sub-units. As a corollary to this, we recommend that top level request and response types contain only sub-messages (no primitive fields). Even when you only need a single primitive type today, having it wrapped in a message gives you a clear path to expand that type and share the type among other methods that return the similar values. |
Thanks for the comprehensive answers - appreciate your answers, that's really useful. Just to confirm on the naming - the original example from the guidance:
|
Definitely on the right track. Let's try something a little more concrete like this:
In this example, Now, if we later need to add a Likewise, if we need to update Even though it may be unlikely Also, having even simple types like Hope this helps. |
The guideline here https://protobuf.dev/programming-guides/style/#services suggests that RPC parameter names should mirrow RPC method names:
service FooService {
rpc GetSomething(GetSomethingRequest) returns (GetSomethingResponse);
rpc ListSomething(ListSomethingRequest) returns (ListSomethingResponse);
}
This makes it really inconvenient to follow when you want to re-use SomethingRequest/SomethingResponse in two different methods. Could you please change the guideline to remove Get/List prefixes, otherwise this leads to artificial limitation that each RPC function has to have a unique parameter type, which isn't mentioned anywhere in the documentation.
The text was updated successfully, but these errors were encountered: