Allow generating only async or sync code#214
Open
anuraaga wants to merge 1 commit intoconnectrpc:mainfrom
Open
Allow generating only async or sync code#214anuraaga wants to merge 1 commit intoconnectrpc:mainfrom
anuraaga wants to merge 1 commit intoconnectrpc:mainfrom
Conversation
Signed-off-by: Anuraag Agrawal <anuraaga@gmail.com>
stefanvanburen
approved these changes
Apr 13, 2026
Comment on lines
+73
to
+80
| switch value { | ||
| case "true": | ||
| trueVal := true | ||
| cfg.Async = &trueVal | ||
| case "false": | ||
| falseVal := false | ||
| cfg.Async = &falseVal | ||
| } |
Member
There was a problem hiding this comment.
first time looking closely at the option parsing, but: should we be failing here on unrecognized option keys/values? (see https://github.com/connectrpc/connect-go/blob/e299aa60ffcf91633e48fcb3dd594cbbb187ec7f/cmd/protoc-gen-connect-go/main.go#L779)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #209
Thanks for the idea @jeffsawatzky - I also know codebases that are relatively new and can be async-only, etc, so being able to simplify the generated code looks like a good idea.
I didn't provide separate options for client vs server - I think the use case is codebases, so either you're mixed and should generate all of it or you're not.
The option name itself was challenging - we use
mode=asyncmode=syncin our unit tests but I don't thinkmodeis a good word for a public API. So I went with a tri-state bool on just the option nameasync.This doesn't touch the import statements for now - in the medium future we will be replacing the plugin framework with something smarter than string replacement, which will also handle import optimization. Until then, I'd like to avoid adding spaghetti to the import statements - it should work great to have ruff automatically optimize the imports after generation.