mirror of
https://git.asonix.dog/asonix/pict-rs
synced 2024-12-22 19:31:35 +00:00
Enable running on bare tokio
This commit is contained in:
parent
7f5cbc4571
commit
4a45aa889c
2 changed files with 31 additions and 7 deletions
|
@ -2072,6 +2072,13 @@ impl PictRsConfiguration {
|
||||||
Ok(self)
|
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
|
/// Run the pict-rs application
|
||||||
pub async fn run(self) -> color_eyre::Result<()> {
|
pub async fn run(self) -> color_eyre::Result<()> {
|
||||||
let PictRsConfiguration { config, operation } = self;
|
let PictRsConfiguration { config, operation } = self;
|
||||||
|
|
31
src/main.rs
31
src/main.rs
|
@ -1,9 +1,26 @@
|
||||||
fn main() -> color_eyre::Result<()> {
|
fn main() -> color_eyre::Result<()> {
|
||||||
actix_web::rt::System::new().block_on(async move {
|
#[cfg(not(feature = "io-uring"))]
|
||||||
pict_rs::PictRsConfiguration::build_default()?
|
return run_tokio();
|
||||||
.install_tracing()?
|
|
||||||
.install_metrics()?
|
#[cfg(feature = "io-uring")]
|
||||||
.run()
|
return run_tokio_uring();
|
||||||
.await
|
}
|
||||||
})
|
|
||||||
|
#[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
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue