hyperium / tonic

A native gRPC client & server implementation with async/await support.
https://docs.rs/tonic
MIT License
9.35k stars 957 forks source link

feat: support `async_trait`-less generation #1697

Open jun-sheaf opened 2 months ago

jun-sheaf commented 2 months ago

Motivation

async_trait is not necessary for most use-cases. This PR provides the option for users.

Solution

Providing an option to generate async traits without async_trait.

Fixed: https://github.com/hyperium/tonic/issues/1651

jun-sheaf commented 1 month ago

@LucioFranco Note that the current CI doesn't test all feature combinations. We should use cargo hack --feature-powerset test to ensure all features are covered.

LucioFranco commented 2 weeks ago

I think we need to generate the code as fn foo() -> impl Future + Send to allow sendable futures. We also need to check if the generated functions will work with the Arc since that also needs Sync. I would like to move in this direction but I don't feel like there is a huge rush. I would like to see some more tests as well checking all the permutations of sendiness/syncness so that we know this will work for users.