Spawns a named server task. If the future completes while `shutdown` has not been requested, this is treated as an unexpected exit and `abort` is cancelled to trigger shutdown of all remaining components. This also fires on panics via the [`ShutdownGuard`] drop implementation.
(
&self,
name: &'static str,
future: impl Future<Output = Result<(), Report<GraphError>>> + Send + 'static,
)
| 61 | /// unexpected exit and `abort` is cancelled to trigger shutdown of all remaining components. |
| 62 | /// This also fires on panics via the [`ShutdownGuard`] drop implementation. |
| 63 | pub(crate) fn spawn( |
| 64 | &self, |
| 65 | name: &'static str, |
| 66 | future: impl Future<Output = Result<(), Report<GraphError>>> + Send + 'static, |
| 67 | ) { |
| 68 | let shutdown = self.shutdown.clone(); |
| 69 | let abort = self.abort.clone(); |
| 70 | self.tracker.spawn(async move { |
| 71 | let _guard = ShutdownGuard { |
| 72 | name, |
| 73 | shutdown, |
| 74 | abort, |
| 75 | }; |
| 76 | if let Err(report) = future.await { |
| 77 | tracing::error!(error = ?report, "{name} failed"); |
| 78 | } |
| 79 | }); |
| 80 | } |
| 81 | |
| 82 | /// Initiates graceful shutdown and waits for all tasks to drain. |
| 83 | pub(crate) async fn shutdown_and_wait(&self) { |
no test coverage detected