Перейти к основному содержимому
Эта страница ещё не переведена

Ниже показан английский оригинал.

Run

run starts the service and serves until SIGINT or SIGTERM, then shuts it down gracefully.

run is the whole process: it connects the brokers, opens the subscriptions and runs the startup hooks, then waits for a signal. A startup failure is the error it returns. A signal starts the same shutdown a started service gets. A subscriber that fails fast tears the service down, and run returns that failure as its error. A subscription whose stream ends while the service runs does the same under SubscriptionEnd::FailFast. The main that #[ruststream::app] generates calls run.

Example​

/// Runs the service until `SIGINT` or `SIGTERM`, then shuts it down gracefully.
async fn serve_forever(broker: MemoryBroker) -> Result<(), Box<dyn Error>> {
app(broker).run().await?;
Ok(())
}