Closed DAOCUONG closed 4 years ago
Thanks you for your info, i need to use actor model for handle nat connection there for i cant call client.connect from async function. I want to block_on client.connet(). as you mention tokio runtime can do that i have tried following code:
let f = natsclient.connect();
let mut rt = Runtime::new().unwrap();
rt.block_on(f);
I got error lock_on(f);
| ^ the trait futures::future::Future
is not implemented for impl core::future::future::Future
Any suggestion what api i should use to block on client.connect
FYI Using futures::executor also crashed
let f = natsclient.connect();
futures::executor::block_on(f);
I added an example of using the client in a blocking context. Although, if you are using the client synchronously it might be better to use one of the other clients.
@davidMcneil thanks you so much for helping i absolutely want to do async way, i using nats client with actor model (riker) super visor will send message for all worker to connect , i would like use client.connect async way too
@DAOCUONG Cool, sounds like an interesting use case. I found this issue in riker that might answer some questions in regard to spawning a future within an actor.
I am going to close this for now, but feel free to reopen or open another issue if you run into more problems. Thanks for using the library!
I tried to use task::block_on (async-std) for above connect function it crashed