Uses Config::tick_interval (#4193)

This commit is contained in:
Emmanuel Keller 2024-06-14 10:41:01 +01:00 committed by GitHub
parent 17ea0d881e
commit 3321c64df7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 9 additions and 4 deletions

View file

@ -23,3 +23,10 @@ impl Default for EngineOptions {
}
}
}
impl EngineOptions {
pub fn with_tick_interval(mut self, tick_interval: Duration) -> Self {
self.tick_interval = tick_interval;
self
}
}

View file

@ -4,7 +4,6 @@ use std::{net::SocketAddr, path::PathBuf};
pub static CF: OnceLock<Config> = OnceLock::new();
use std::time::Duration;
use surrealdb::options::EngineOptions;
#[derive(Clone, Debug)]
@ -16,7 +15,6 @@ pub struct Config {
pub pass: Option<String>,
pub crt: Option<PathBuf>,
pub key: Option<PathBuf>,
pub tick_interval: Duration,
pub engine: Option<EngineOptions>,
pub no_identification_headers: bool,
}

View file

@ -15,6 +15,7 @@ use std::path::PathBuf;
use std::time::Duration;
use surrealdb::engine::any::IntoEndpoint;
use surrealdb::engine::tasks::start_tasks;
use surrealdb::options::EngineOptions;
use tokio_util::sync::CancellationToken;
#[derive(Args, Debug)]
@ -174,11 +175,10 @@ pub async fn init(
path,
user,
pass,
tick_interval,
no_identification_headers,
crt: web.as_ref().and_then(|x| x.web_crt.clone()),
key: web.as_ref().and_then(|x| x.web_key.clone()),
engine: None,
engine: Some(EngineOptions::default().with_tick_interval(tick_interval)),
});
// This is the cancellation token propagated down to
// all the async functions that needs to be stopped gracefully.