Update generated service and client class names to better handle well-named services.#97
Update generated service and client class names to better handle well-named services.#97darronschall wants to merge 2 commits intoarthurnn:mainfrom
Conversation
…es are not properly named. Protobuf services should end in `Service`. This is a [buf lint rule](https://github.com/bufbuild/buf-examples/blob/main/linting/bad/acme/weather/v1/weather.proto#L39), recommended via [the protobuf style guide](https://developers.google.com/protocol-buffers/docs/style#services), and demonstrated in [Twirp Best Practices](https://twitchtv.github.io/twirp/docs/best_practices.html)) This change avoids generating class names such as `MessagesServiceService`.
…vices. Similar to 5322b13, for well-named services that end in "Service", this change prevents the generated clients from being named like "MessagesServiceClient".
|
thanks @darronschall , I have this on my schedule to test against some local projects. At first glance it looks good. thanks again for the contribution. |
|
I am putting a pin on this until I figure out what to do about the latest version hiccups. see #99. thanks, and I added this back to my backlog to review by the end of the week |
|
@arthurnn Just wanted to check in since it's been a few months. Have you been able to take a look at this yet? No rush, and no pressure. It'd be nice to land this at some point. |
|
@arthurnn any chance we can get some eyes on this? It continues to be an annoyance for us. Happy to assist with review and/or maintenance if it'd help. |
|
This would be a nice improvement. We run in to these when trying to respect service name lint rules. |
|
To clarify the problem again, when I have a service that ends in |
This PR follows #91 and subsequent discussions.
When a service is well-named and ends in "Service", such as "MessagesService", the generator generates
class MessagesServiceService < Twirp::Seriviceandclass MessagesServiceClient < Twirp::Client.This change causes the generator to generate
class MessagesService < Twirp::Seriviceandclass MessagesClient < Twirp::Clientinstead.The service name passed to the
serviceDSL is not impacted (which was the problem in #91 that needed a revert).For backwards compatibility, this change does not impact the current hello_world example, as demonstrated by:
I'm not familiar enough with go and testing to write tests for this in
main_test.go. Any help there is appreciated.