Repository navigation
Executing code after a stream is finished. #2429
Replies: 1 comment
|
The reason code placed between To execute code after all items in the stream have been emitted, you can place your code directly at the end of the The let output = async_stream::try_stream! {
// 1. Stream your items to the client
for item in items {
// ...
yield rpc_deployment;
}
// 2. This executes AFTER all items above have been yielded and consumed
println!("Stream finished successfully, executing post-processing...");
do_cleanup().await;
};(Note: If you also need cleanup to run even when a client cancels or disconnects mid-stream before all items are sent, you can hold an RAII drop guard or send a completion signal via a |
Uh oh!
There was an error while loading. Please reload this page.
Hello,
I have got the following proto
The Tonic service looks as follows.
Want I want is execute some code after all incoming streamed messages have been converted into a response per item. If I put it between
letandOk()it is not executed after the stream is finished. How should I achieve this?All reactions