MCPcopy Create free account
hub / github.com/hashintel/hash / spawn

Method spawn

apps/hash-graph/src/subcommand/mod.rs:63–80  ·  view source on GitHub ↗

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,
    )

Source from the content-addressed store, hash-verified

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) {

Callers 5

start_rest_serverFunction · 0.45
start_rpc_serverFunction · 0.45
serverFunction · 0.45
start_type_fetcherFunction · 0.45
start_admin_serverFunction · 0.45

Calls 1

cloneMethod · 0.45

Tested by

no test coverage detected