mirror of
https://github.com/OMGeeky/tarpc.git
synced 2026-01-24 11:40:22 +01:00
Don't bake in Send + 'static.
Send + 'static was baked in to make it possible to spawn futures onto the default executor. We can accomplish the same thing by offering helper fns that do the spawning while not requiring it for the rest of the functionality. Fixes https://github.com/google/tarpc/issues/212
This commit is contained in:
@@ -46,7 +46,7 @@ async fn main() -> io::Result<()> {
|
||||
|
||||
// WorldClient is generated by the service attribute. It has a constructor `new` that takes a
|
||||
// config and any Transport as input.
|
||||
let mut client = service::WorldClient::new(client::Config::default(), transport).await?;
|
||||
let mut client = service::WorldClient::new(client::Config::default(), transport).spawn()?;
|
||||
|
||||
// The client has an RPC method for each RPC defined in the annotated trait. It takes the same
|
||||
// args as defined, with the addition of a Context, which is always the first arg. The Context
|
||||
|
||||
@@ -75,11 +75,11 @@ async fn main() -> io::Result<()> {
|
||||
// the generated World trait.
|
||||
.map(|channel| {
|
||||
let server = HelloServer(channel.as_ref().as_ref().peer_addr().unwrap());
|
||||
channel.respond_with(server.serve())
|
||||
channel.respond_with(server.serve()).execute()
|
||||
})
|
||||
// Max 10 channels.
|
||||
.buffer_unordered(10)
|
||||
.for_each(|_| futures::future::ready(()))
|
||||
.for_each(|_| async {})
|
||||
.await;
|
||||
|
||||
Ok(())
|
||||
|
||||
Reference in New Issue
Block a user