Repository: seanmonstar/warp (language: rust)

Issue:
There is no `try_bind_with_graceful_shutdown`
We have `try_bind`, and `bind_with_graceful_shutdown`, but not the combination of the two. 


Discussion / hints:

Fix patch:
diff --git a/src/server.rs b/src/server.rs
index 3736fca96..a33e9c42a 100644
--- a/src/server.rs
+++ b/src/server.rs
@@ -287,6 +287,26 @@ where
         (addr, fut)
     }
 
+    /// Create a server with graceful shutdown signal.
+    ///
+    /// When the signal completes, the server will start the graceful shutdown
+    /// process.
+    pub fn try_bind_with_graceful_shutdown(
+        self,
+        addr: impl Into<SocketAddr> + 'static,
+        signal: impl Future<Output = ()> + Send + 'static,
+    ) -> Result<(SocketAddr, impl Future<Output = ()> + 'static), crate::Error> {
+        let addr = addr.into();
+        let (addr, srv) = try_bind!(self, &addr).map_err(crate::Error::new)?;
+        let srv = srv.with_graceful_shutdown(signal).map(|result| {
+            if let Err(err) = result {
+                log::error!("server error: {}", err)
+            }
+        });
+
+        Ok((addr, srv))
+    }
+
     /// Setup this `Server` with a specific stream of incoming connections.
     ///
     /// This can be used for Unix Domain Sockets, or TLS, etc.


Test patch: