mirror of
https://git.asonix.dog/asonix/pict-rs
synced 2024-12-22 11:21:24 +00:00
Build same pict-rs config for either runtime option
This commit is contained in:
parent
f97f76c01e
commit
3f5bc1d311
2 changed files with 15 additions and 16 deletions
|
@ -2080,6 +2080,9 @@ impl PictRsConfiguration {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Run the pict-rs application
|
/// Run the pict-rs application
|
||||||
|
///
|
||||||
|
/// This must be called from within a tokio `LocalSet`, which is created by default for
|
||||||
|
/// actix-rt runtimes, and by tokio_uring
|
||||||
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;
|
||||||
|
|
||||||
|
|
28
src/main.rs
28
src/main.rs
|
@ -1,24 +1,20 @@
|
||||||
fn main() -> color_eyre::Result<()> {
|
fn main() -> color_eyre::Result<()> {
|
||||||
run()
|
let config = pict_rs::PictRsConfiguration::build_default()?
|
||||||
|
.install_tracing()?
|
||||||
|
.install_metrics()?;
|
||||||
|
|
||||||
|
run(config)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "io-uring")]
|
#[cfg(feature = "io-uring")]
|
||||||
fn run() -> color_eyre::Result<()> {
|
fn run(config: pict_rs::PictRsConfiguration) -> color_eyre::Result<()> {
|
||||||
tokio_uring::start(async move {
|
tokio_uring::start(config.run())
|
||||||
pict_rs::PictRsConfiguration::build_default()?
|
|
||||||
.install_tracing()?
|
|
||||||
.install_metrics()?
|
|
||||||
.run()
|
|
||||||
.await
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(feature = "io-uring"))]
|
#[cfg(not(feature = "io-uring"))]
|
||||||
#[tokio::main]
|
fn run(config: pict_rs::PictRsConfiguration) -> color_eyre::Result<()> {
|
||||||
async fn run() -> color_eyre::Result<()> {
|
tokio::runtime::Builder::new_multi_thread()
|
||||||
pict_rs::PictRsConfiguration::build_default()?
|
.enable_all()
|
||||||
.install_tracing()?
|
.build()?
|
||||||
.install_metrics()?
|
.block_on(config.run())
|
||||||
.run_on_localset()
|
|
||||||
.await
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue