From 139b0fdc3ebea2f4f8bfc6b77f3aba8c0bdc42de Mon Sep 17 00:00:00 2001 From: strawberry Date: Wed, 6 Mar 2024 18:14:30 -0500 Subject: [PATCH] add global flush function Signed-off-by: strawberry --- src/database/key_value/globals.rs | 2 ++ src/service/globals/data.rs | 1 + src/service/globals/mod.rs | 2 ++ 3 files changed, 5 insertions(+) diff --git a/src/database/key_value/globals.rs b/src/database/key_value/globals.rs index e24c6047..6c8e5b7d 100644 --- a/src/database/key_value/globals.rs +++ b/src/database/key_value/globals.rs @@ -116,6 +116,8 @@ impl service::globals::Data for KeyValueDatabase { fn cleanup(&self) -> Result<()> { self.db.cleanup() } + fn flush(&self) -> Result<()> { self.db.flush() } + fn memory_usage(&self) -> String { let pdu_cache = self.pdu_cache.lock().unwrap().len(); let shorteventid_cache = self.shorteventid_cache.lock().unwrap().len(); diff --git a/src/service/globals/data.rs b/src/service/globals/data.rs index 1ae76d21..a829938e 100644 --- a/src/service/globals/data.rs +++ b/src/service/globals/data.rs @@ -17,6 +17,7 @@ pub trait Data: Send + Sync { fn update_check_for_updates_id(&self, id: u64) -> Result<()>; async fn watch(&self, user_id: &UserId, device_id: &DeviceId) -> Result<()>; fn cleanup(&self) -> Result<()>; + fn flush(&self) -> Result<()>; fn memory_usage(&self) -> String; fn clear_caches(&self, amount: u32); fn load_keypair(&self) -> Result; diff --git a/src/service/globals/mod.rs b/src/service/globals/mod.rs index c0b2db3c..ec069588 100644 --- a/src/service/globals/mod.rs +++ b/src/service/globals/mod.rs @@ -274,6 +274,8 @@ impl Service<'_> { pub fn cleanup(&self) -> Result<()> { self.db.cleanup() } + pub fn flush(&self) -> Result<()> { self.db.flush() } + pub fn server_name(&self) -> &ServerName { self.config.server_name.as_ref() } pub fn max_request_size(&self) -> u32 { self.config.max_request_size }