Skip to content
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

Would it be feasible to remove async-trait from codegen-ed server traits? #1998

Open
kanpov opened this issue Oct 13, 2024 · 0 comments
Open

Comments

@kanpov
Copy link

kanpov commented Oct 13, 2024

Feature Request

Crates

tonic
tonic-build (for an option to pin-box the futures in the codegen builders)

Motivation

Benefits:

  • Removal of a dependency
  • Reduction in compilation times for pretty much all tonic-based projects since the async-trait proc macro no longer would need to be invoked by the compiler
  • async_trait is no longer reexported by tonic as #[tonic::async_trait]

Drawbacks:

  • Breaking change

Proposal

Instead, the codegen could just spit out a normal trait with fn ... -> impl Future<Output = ...> + Send, and in rare cases where the server traits need object safety (of which there are pretty much none, but just leaving this to contradict the argument of async_trait ever being a good idea to use post-1.75), there could be an opt-in option to use fn ... -> Pin<Box<dyn Future<Output = ...> + Send>> instead.

Alternatives

Keeping async-trait.

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

No branches or pull requests

1 participant