mirror of
https://git.asonix.dog/asonix/pict-rs
synced 2024-11-20 11:21:14 +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
|
||||
///
|
||||
/// 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<()> {
|
||||
let PictRsConfiguration { config, operation } = self;
|
||||
|
||||
|
|
28
src/main.rs
28
src/main.rs
|
@ -1,24 +1,20 @@
|
|||
fn main() -> color_eyre::Result<()> {
|
||||
run()
|
||||
let config = pict_rs::PictRsConfiguration::build_default()?
|
||||
.install_tracing()?
|
||||
.install_metrics()?;
|
||||
|
||||
run(config)
|
||||
}
|
||||
|
||||
#[cfg(feature = "io-uring")]
|
||||
fn run() -> color_eyre::Result<()> {
|
||||
tokio_uring::start(async move {
|
||||
pict_rs::PictRsConfiguration::build_default()?
|
||||
.install_tracing()?
|
||||
.install_metrics()?
|
||||
.run()
|
||||
.await
|
||||
})
|
||||
fn run(config: pict_rs::PictRsConfiguration) -> color_eyre::Result<()> {
|
||||
tokio_uring::start(config.run())
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "io-uring"))]
|
||||
#[tokio::main]
|
||||
async fn run() -> color_eyre::Result<()> {
|
||||
pict_rs::PictRsConfiguration::build_default()?
|
||||
.install_tracing()?
|
||||
.install_metrics()?
|
||||
.run_on_localset()
|
||||
.await
|
||||
fn run(config: pict_rs::PictRsConfiguration) -> color_eyre::Result<()> {
|
||||
tokio::runtime::Builder::new_multi_thread()
|
||||
.enable_all()
|
||||
.build()?
|
||||
.block_on(config.run())
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue