-
Notifications
You must be signed in to change notification settings - Fork 60
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
Update generated service and client class names to better handle well-named services. #97
base: main
Are you sure you want to change the base?
Update generated service and client class names to better handle well-named services. #97
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::Serivice
andclass MessagesServiceClient < Twirp::Client
.This change causes the generator to generate
class MessagesService < Twirp::Serivice
andclass MessagesClient < Twirp::Client
instead.The service name passed to the
service
DSL 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.