Skip to main content

Start

start brings the service up and returns a RunningApp, so the caller owns the process and decides when it stops.

start connects the brokers, opens the subscriptions and runs the startup hooks, then returns. A startup failure is the error start returns, before the caller accepts its own traffic. start installs no signal handlers: the caller stops the service with shutdown. The RunningApp also hands out the service's health and publishers for tasks beside it, as the HTTP page shows.

Example​

/// Starts the service beside other work of the process, and stops it once that work is done.
async fn serve(
broker: MemoryBroker,
work: impl Future<Output = ()> + Send,
) -> Result<(), Box<dyn Error>> {
// `start` returns once every subscription is open.
let running = app(broker).start().await?;
work.await;
running.shutdown().await?;
Ok(())
}