Allow tracing filters to be changed at runtime

ReloadHandle is taken from conduwuit commit
8a5599adf9eafe9111f3d1597f8fb333b8b76849, authored by Benjamin.

Co-authored-by: Benjamin Lee <benjamin@computer.surgery>
This commit is contained in:
Lambda 2024-06-07 16:45:52 +00:00 committed by Charles Hall
parent f576aff7eb
commit f89e1c7dfc
No known key found for this signature in database
GPG key ID: 7B8E0645816E07CF
7 changed files with 145 additions and 29 deletions

View file

@ -25,8 +25,9 @@ use ruma::{
use tracing::{debug, error, info, info_span, warn, Instrument};
use crate::{
config::DatabaseBackend, service::rooms::timeline::PduCount, services,
utils, Config, Error, PduEvent, Result, Services, SERVICES,
config::DatabaseBackend, observability::FilterReloadHandles,
service::rooms::timeline::PduCount, services, utils, Config, Error,
PduEvent, Result, Services, SERVICES,
};
pub(crate) struct KeyValueDatabase {
@ -310,7 +311,10 @@ impl KeyValueDatabase {
allow(unreachable_code)
)]
#[allow(clippy::too_many_lines)]
pub(crate) async fn load_or_create(config: Config) -> Result<()> {
pub(crate) async fn load_or_create(
config: Config,
reload_handles: FilterReloadHandles,
) -> Result<()> {
Self::check_db_setup(&config)?;
if !Path::new(&config.database.path).exists() {
@ -527,7 +531,8 @@ impl KeyValueDatabase {
let db = Box::leak(db_raw);
let services_raw = Box::new(Services::build(db, config)?);
let services_raw =
Box::new(Services::build(db, config, reload_handles)?);
// This is the first and only time we initialize the SERVICE static
*SERVICES.write().unwrap() = Some(Box::leak(services_raw));