-
Notifications
You must be signed in to change notification settings - Fork 8
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
UTransport::receive should support specifying max-time-to-wait #45
Comments
@AnotherDaniel @PLeVasseur WDYT? |
Probably one of the cases where actual API usage data might be interesting ('does anyone really ever use a value different from 0?'). |
Interesting thought... Hmmm. Similar to Daniel, I'm wondering if this is something that should be baked into the API. It seems like the Rust async ecosystem ( e.g. use std::time::Duration;
use async_std::future;
let never = future::pending::<()>();
let dur = Duration::from_millis(5);
assert!(future::timeout(dur, never).await.is_err()); use tokio::time::timeout;
use tokio::sync::oneshot;
use std::time::Duration;
let (tx, rx) = oneshot::channel();
// Wrap the future with a `Timeout` set to expire in 10 milliseconds.
if let Err(_) = timeout(Duration::from_millis(10), rx).await {
println!("did not receive value within 10 ms");
} I'm wondering if we maybe start with suggesting these routes in the docs and experimenting with them as needed and see how common this is, in order to consider inclusion. WDYT? |
Your code examples would only work if the Many messaging systems therefore provide this functionality in their own client polling API as well.
For the moment, we should be able to simply assume that if no message is available immediately, we simply return with an error. However, we will need to document this behavior properly in the function's doc comment. |
It is unclear how the
UTransport::receive
function handles situations where no message is (immediately) available on the given topic, i.e. when will the returned future be completed?FMPOV the function should accept an argument indicating for how long the client wants to wait, e.g.
0
= fail immediately if no message is available, andt > 0
= fail after t milliseconds without a being message available:The text was updated successfully, but these errors were encountered: