-
Notifications
You must be signed in to change notification settings - Fork 13
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
Can we add frame for a function that reutrns Poll<T>
?
#32
Comments
Hi @Xuanwo! I apologize for the slow response — I was on an extended leave from work. I think this is possible. I'll look into it. |
Can you point me to a type in OpenDAL that implements I think I have a solution that could work for this use-case, but I'd like to be sure. |
Sure! Here is the code where we added async-backtrace: https://github.com/apache/incubator-opendal/blob/main/core/src/layers/async_backtrace.rs. Currently, we have only added framed for async functions, and we expect to have them on our Readers just like we do for logging: https://github.com/apache/incubator-opendal/blob/main/core/src/layers/logging.rs#L992-L1037. We plan to return an |
I'm experimenting with approaches on the I've started by making our pin_project! {
#[must_use = "streams do nothing unless you `.await` or poll them"]
pub struct Take<R> {
#[pin]
inner: R,
// Add a `Frame` field to your type.
#[pin]
frame: async_backtrace::Frame,
limit: u64,
}
}
impl<R: AsyncRead> AsyncRead for Take<R> {
fn poll_read(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
buf: &mut ReadBuf<'_>,
) -> Poll<Result<(), std::io::Error>> {
// And run your async routines `in_scope` of `Frame`.
let this = self.project();
this.frame.in_scope(|| {
unimplemented!("method internals go here")
})
}
} Does this work for you? This is fine for |
Cool! I will give it a try.
|
Hi @jswrenn, thanks for your work! This solution works for us. However, we've migrated to an |
Hi, thanks for creating this lib! OpenDAL is working on for adding native integration with this lib to allow users to dump the async backtrace: apache/opendal#2765.
But we met a problem that we have some trait like
AsyncRead
returnsPoll<T>
. Can we add frame for them?The text was updated successfully, but these errors were encountered: