Enable running on bare tokio
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
asonix 2023-10-07 11:48:58 -05:00
parent 7f5cbc4571
commit 4a45aa889c
2 changed files with 31 additions and 7 deletions

View file

@ -2072,6 +2072,13 @@ impl PictRsConfiguration {
Ok(self)
}
/// Run the pict-rs application on a tokio `LocalSet`
///
/// This must be called from within `tokio::main` directly
pub async fn run_on_localset(self) -> color_eyre::Result<()> {
tokio::task::LocalSet::new().run_until(self.run()).await
}
/// Run the pict-rs application
pub async fn run(self) -> color_eyre::Result<()> {
let PictRsConfiguration { config, operation } = self;

View file

@ -1,9 +1,26 @@
fn main() -> color_eyre::Result<()> {
actix_web::rt::System::new().block_on(async move {
pict_rs::PictRsConfiguration::build_default()?
.install_tracing()?
.install_metrics()?
.run()
.await
})
#[cfg(not(feature = "io-uring"))]
return run_tokio();
#[cfg(feature = "io-uring")]
return run_tokio_uring();
}
#[cfg(feature = "io-uring")]
fn run_tokio_uring() -> color_eyre::Result<()> {
tokio_uring::start(run())
}
#[cfg(not(feature = "io-uring"))]
#[tokio::main]
async fn run_tokio() -> color_eyre::Result<()> {
run().await
}
async fn run() -> color_eyre::Result<()> {
pict_rs::PictRsConfiguration::build_default()?
.install_tracing()?
.install_metrics()?
.run_on_localset()
.await
}