-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Open
Labels
C-featureCategory: feature. This is adding a new feature.Category: feature. This is adding a new feature.
Description
Describe the solution you'd like
I'm using hyper::body::Sender to send an SSE stream to the client. For each connection there is an associated Tokio task that subscribes to a distributed message queue, and I would like to stop the task on client disconnection. It seems that currently there isn't a method on Sender that allows to detect disconnection without attempting to send a message.
I think an API like this would work:
impl Sender {
pub async fn wait_disconnect(&mut self) -> Result<()>;
}Describe alternatives you've considered
- Send heartbeat messages to the client periodically and stop the task on failure.
- Periodically call
poll_ready.
I'm already doing 1 anyway, but this adds latency between the client closing the connection and the server stopping the task, even when the connection is gracefully shut down.
nwtgck, magurotuna and lucacasonato
Metadata
Metadata
Assignees
Labels
C-featureCategory: feature. This is adding a new feature.Category: feature. This is adding a new feature.