Skip to content

Conversation

sticnarf
Copy link

@sticnarf sticnarf commented Dec 6, 2023

I want await-tree to track a request stream passed to tonic. But the root future of tonic is apparently not under our control.

let req_stream = async_stream! {
    while x {
        whatever_fut.instrument_await("y").await; // not under any tree
        yield z;
    }
};
tonic_client.stream_rpc(req_stream);

And it doesn't work to use a customized executor that wraps every future with a TreeRoot. (Flood of future polled in a different context as it was first polled and future is dropped in a different context as it was first poll).

So, the best we can do is create a TreeRoot for the stream:

tonic_client.stream_rpc(tree_root.instrument_stream(req_stream));

@sticnarf sticnarf requested a review from BugenZhao as a code owner December 6, 2023 09:57
Copy link
Member

@BugenZhao BugenZhao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants