Skip to content
This repository has been archived by the owner on Oct 31, 2024. It is now read-only.

feat: terminate stream if client is dropping the connection #463

Merged
merged 10 commits into from
Mar 5, 2024
Prev Previous commit
Next Next commit
fix: testing
gruberb committed Feb 29, 2024
commit c03638eee5fe596e33993179f82f10f51ead9ba2
34 changes: 19 additions & 15 deletions crates/topos-tce-api/src/stream/mod.rs
Original file line number Diff line number Diff line change
@@ -152,25 +152,29 @@ impl Stream {

// We currently open the stream, but no other message from the client is getting processed.
// We are using this open connection to communicate `delivered_certificates` to the client.
stream_packet = self.inbound_stream.next() => {
if let Some(stream_packet) = stream_packet {
match stream_packet {
Ok((request_id, _message)) => {
debug!("Received message for stream: {request_id:?}");
}
Err(error) => {
// In case the stream is getting closed from the client side for example
error!("Stream error: {error:?}");
break;
}
Some(stream_packet) = self.inbound_stream.next() => {
match stream_packet {
Ok((request_id, _message)) => {
debug!("Received message for stream: {request_id:?}");
}
} else {
debug!("Stream is closed, exiting");
break;
}
Err(error) => {
// In case the stream is getting closed from the client side for example
error!("Stream error: {error:?}");
break;
}
}
}



// Some(_stream_packet) = self.inbound_stream.next() => {
//
// }

else => break,
}
}

Ok(self.stream_id)
}
}