-
Notifications
You must be signed in to change notification settings - Fork 203
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
Future returned by Serve::serve()
is not Send
#421
Comments
Hi, thanks for raising this issue! In the example service, it does spawn the serve futures. Any idea what's different in yours? I suspect the issue is that your code is trying to be generic over multiple services? |
Yes, it is because I'm trying to make a generic function. Although in all generated trait implementations, the future returned by |
Skipping tarpc 0.34 which introduced a breaking change. See google/tarpc#421.
How large of a library are you writing that is generic over tarpc service functions? And how many tarpc services do you expect to use the library? I'm trying to gauge whether it'd be practical to just write the code once per service. |
Writing code for each service indeed would work for me. I only have two concrete service type to support. Feel free to close as "working as intended". |
Thanks for the details! I'll keep this issue open, because I would like to fix it eventually, potentially just waiting for Rust to offer a more complete solution. |
@tikue what do you think about adding in trait-variant? It fixes this use case (I tested it in my fork), and is officially suggested by the Rust lang team. Only hiccup is that usage of that macro would conflict with this blanket impl, which I'm not sure of a solution too without specialization or negative bounds. I'm happy to work through a PR 🙂 |
@ShaneMurphy2 I'd be happy to review a PR if you want to work on it! Does trait variant need to be used on both |
In my opinion it's a little early to have |
For the blanket impl of Stub, you could probably add a fn to Serve that converts it to Stub. |
Are you thinking a signature like this in async fn into_stub(self) -> impl Stub; |
I have a WIP branch up here: https://github.com/ShaneMurphy2/tarpc/tree/trait-variant |
I'm trying to write a function that starts a server with a clonable
Serve
.That turns out to be impossible because I cannot call
tokio::spawn()
on the future returned byServe::serve
. The future is not guaranteed to beSend
. Same applies to any future that wraps aserve()
future.This is a well-known problem caused by using
aysnc fn
in public traits. There is a solution described in the same article. Can we apply the solution here?The text was updated successfully, but these errors were encountered: