iroh_http_core/http/server/
handle.rs1use std::sync::Arc;
7
8pub struct ServeHandle {
9 pub(super) join: tokio::task::JoinHandle<()>,
10 pub(super) shutdown_notify: Arc<tokio::sync::Notify>,
11 pub(super) drain_timeout: std::time::Duration,
12 pub(super) done_rx: tokio::sync::watch::Receiver<bool>,
14}
15
16impl ServeHandle {
17 pub fn shutdown(&self) {
18 self.shutdown_notify.notify_one();
19 }
20 pub async fn drain(self) {
21 self.shutdown();
22 let _ = self.join.await;
23 }
24 pub fn abort(&self) {
25 self.join.abort();
26 }
27 pub fn drain_timeout(&self) -> std::time::Duration {
28 self.drain_timeout
29 }
30 pub fn subscribe_done(&self) -> tokio::sync::watch::Receiver<bool> {
35 self.done_rx.clone()
36 }
37}