change rustfmt configuration

This change is fully automated, except the `rustfmt.toml` changes and
a few clippy directives to allow specific functions with too many lines
because they are longer now.
This commit is contained in:
Charles Hall 2024-05-16 01:19:04 -07:00
parent 40d6ce230d
commit 0afc1d2f50
No known key found for this signature in database
GPG key ID: 7B8E0645816E07CF
123 changed files with 7881 additions and 4687 deletions

View file

@ -4,10 +4,9 @@ use std::{
};
use lru_cache::LruCache;
use tokio::sync::{broadcast, Mutex};
use tokio::sync::{broadcast, Mutex, RwLock};
use crate::{Config, Result};
use tokio::sync::RwLock;
pub(crate) mod account_data;
pub(crate) mod admin;
@ -58,10 +57,14 @@ impl Services {
) -> Result<Self> {
Ok(Self {
appservice: appservice::Service::build(db)?,
pusher: pusher::Service { db },
pusher: pusher::Service {
db,
},
rooms: rooms::Service {
alias: db,
auth_chain: rooms::auth_chain::Service { db },
auth_chain: rooms::auth_chain::Service {
db,
},
directory: db,
edus: rooms::edus::Service {
read_receipt: db,
@ -78,10 +81,14 @@ impl Services {
},
metadata: db,
outlier: db,
pdu_metadata: rooms::pdu_metadata::Service { db },
pdu_metadata: rooms::pdu_metadata::Service {
db,
},
search: db,
short: db,
state: rooms::state::Service { db },
state: rooms::state::Service {
db,
},
state_accessor: rooms::state_accessor::Service {
db,
#[allow(
@ -101,7 +108,9 @@ impl Services {
(100.0 * config.cache_capacity_modifier) as usize,
)),
},
state_cache: rooms::state_cache::Service { db },
state_cache: rooms::state_cache::Service {
db,
},
state_compressor: rooms::state_compressor::Service {
db,
#[allow(
@ -117,14 +126,18 @@ impl Services {
db,
lasttimelinecount_cache: Mutex::new(HashMap::new()),
},
threads: rooms::threads::Service { db },
threads: rooms::threads::Service {
db,
},
spaces: rooms::spaces::Service {
roomid_spacechunk_cache: Mutex::new(LruCache::new(200)),
},
user: db,
},
transaction_ids: db,
uiaa: uiaa::Service { db },
uiaa: uiaa::Service {
db,
},
users: users::Service {
db,
connections: StdMutex::new(BTreeMap::new()),
@ -132,14 +145,18 @@ impl Services {
account_data: db,
admin: admin::Service::build(),
key_backups: db,
media: media::Service { db },
media: media::Service {
db,
},
sending: sending::Service::build(db, &config),
globals: globals::Service::load(db, config)?,
})
}
async fn memory_usage(&self) -> String {
let lazy_load_waiting = self.rooms.lazy_loading.lazy_load_waiting.lock().await.len();
let lazy_load_waiting =
self.rooms.lazy_loading.lazy_load_waiting.lock().await.len();
let server_visibility_cache = self
.rooms
.state_accessor
@ -154,21 +171,12 @@ impl Services {
.lock()
.unwrap()
.len();
let stateinfo_cache = self
.rooms
.state_compressor
.stateinfo_cache
.lock()
.unwrap()
.len();
let lasttimelinecount_cache = self
.rooms
.timeline
.lasttimelinecount_cache
.lock()
.await
.len();
let roomid_spacechunk_cache = self.rooms.spaces.roomid_spacechunk_cache.lock().await.len();
let stateinfo_cache =
self.rooms.state_compressor.stateinfo_cache.lock().unwrap().len();
let lasttimelinecount_cache =
self.rooms.timeline.lasttimelinecount_cache.lock().await.len();
let roomid_spacechunk_cache =
self.rooms.spaces.roomid_spacechunk_cache.lock().await.len();
format!(
"\
@ -177,18 +185,13 @@ server_visibility_cache: {server_visibility_cache}
user_visibility_cache: {user_visibility_cache}
stateinfo_cache: {stateinfo_cache}
lasttimelinecount_cache: {lasttimelinecount_cache}
roomid_spacechunk_cache: {roomid_spacechunk_cache}\
"
roomid_spacechunk_cache: {roomid_spacechunk_cache}"
)
}
async fn clear_caches(&self, amount: u32) {
if amount > 0 {
self.rooms
.lazy_loading
.lazy_load_waiting
.lock()
.await
.clear();
self.rooms.lazy_loading.lazy_load_waiting.lock().await.clear();
}
if amount > 1 {
self.rooms
@ -207,28 +210,13 @@ roomid_spacechunk_cache: {roomid_spacechunk_cache}\
.clear();
}
if amount > 3 {
self.rooms
.state_compressor
.stateinfo_cache
.lock()
.unwrap()
.clear();
self.rooms.state_compressor.stateinfo_cache.lock().unwrap().clear();
}
if amount > 4 {
self.rooms
.timeline
.lasttimelinecount_cache
.lock()
.await
.clear();
self.rooms.timeline.lasttimelinecount_cache.lock().await.clear();
}
if amount > 5 {
self.rooms
.spaces
.roomid_spacechunk_cache
.lock()
.await
.clear();
self.rooms.spaces.roomid_spacechunk_cache.lock().await.clear();
}
}
}