Skip to content

Allow generating only async or sync code#214

Open
anuraaga wants to merge 1 commit intoconnectrpc:mainfrom
anuraaga:async-sync-only
Open

Allow generating only async or sync code#214
anuraaga wants to merge 1 commit intoconnectrpc:mainfrom
anuraaga:async-sync-only

Conversation

@anuraaga
Copy link
Copy Markdown
Collaborator

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=async mode=sync in our unit tests but I don't think mode is a good word for a public API. So I went with a tri-state bool on just the option name async.

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.

Signed-off-by: Anuraag Agrawal <anuraaga@gmail.com>
@anuraaga anuraaga requested a review from a team April 13, 2026 03:28
Comment on lines +73 to +80
switch value {
case "true":
trueVal := true
cfg.Async = &trueVal
case "false":
falseVal := false
cfg.Async = &falseVal
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request] Option to disable WSGI/Sync code generation

2 participants