mirror of
https://gitlab.computer.surgery/matrix/grapevine.git
synced 2025-12-17 07:41:23 +01:00
add constructor for state accessor service
This commit is contained in:
parent
a083ff9200
commit
c6e2f8372c
2 changed files with 27 additions and 12 deletions
|
|
@ -133,25 +133,25 @@ impl Services {
|
||||||
state: rooms::state::Service {
|
state: rooms::state::Service {
|
||||||
db,
|
db,
|
||||||
},
|
},
|
||||||
state_accessor: rooms::state_accessor::Service {
|
state_accessor: rooms::state_accessor::Service::new(
|
||||||
db,
|
db,
|
||||||
#[allow(
|
#[allow(
|
||||||
clippy::as_conversions,
|
clippy::as_conversions,
|
||||||
clippy::cast_sign_loss,
|
clippy::cast_sign_loss,
|
||||||
clippy::cast_possible_truncation
|
clippy::cast_possible_truncation
|
||||||
)]
|
)]
|
||||||
server_visibility_cache: StdMutex::new(LruCache::new(
|
{
|
||||||
(100.0 * config.cache_capacity_modifier) as usize,
|
(100.0 * config.cache_capacity_modifier) as usize
|
||||||
)),
|
},
|
||||||
#[allow(
|
#[allow(
|
||||||
clippy::as_conversions,
|
clippy::as_conversions,
|
||||||
clippy::cast_sign_loss,
|
clippy::cast_sign_loss,
|
||||||
clippy::cast_possible_truncation
|
clippy::cast_possible_truncation
|
||||||
)]
|
)]
|
||||||
user_visibility_cache: StdMutex::new(LruCache::new(
|
{
|
||||||
(100.0 * config.cache_capacity_modifier) as usize,
|
(100.0 * config.cache_capacity_modifier) as usize
|
||||||
)),
|
},
|
||||||
},
|
),
|
||||||
state_cache: rooms::state_cache::Service::new(db),
|
state_cache: rooms::state_cache::Service::new(db),
|
||||||
state_compressor: rooms::state_compressor::Service {
|
state_compressor: rooms::state_compressor::Service {
|
||||||
db,
|
db,
|
||||||
|
|
|
||||||
|
|
@ -38,14 +38,29 @@ mod data;
|
||||||
pub(crate) use data::Data;
|
pub(crate) use data::Data;
|
||||||
|
|
||||||
pub(crate) struct Service {
|
pub(crate) struct Service {
|
||||||
pub(crate) db: &'static dyn Data,
|
db: &'static dyn Data,
|
||||||
pub(crate) server_visibility_cache:
|
server_visibility_cache:
|
||||||
Mutex<LruCache<(OwnedServerName, ShortStateHash), bool>>,
|
Mutex<LruCache<(OwnedServerName, ShortStateHash), bool>>,
|
||||||
pub(crate) user_visibility_cache:
|
user_visibility_cache: Mutex<LruCache<(OwnedUserId, ShortStateHash), bool>>,
|
||||||
Mutex<LruCache<(OwnedUserId, ShortStateHash), bool>>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Service {
|
impl Service {
|
||||||
|
pub(crate) fn new(
|
||||||
|
db: &'static dyn Data,
|
||||||
|
server_visibility_cache_size: usize,
|
||||||
|
user_visibility_cache_size: usize,
|
||||||
|
) -> Self {
|
||||||
|
Self {
|
||||||
|
db,
|
||||||
|
server_visibility_cache: Mutex::new(LruCache::new(
|
||||||
|
server_visibility_cache_size,
|
||||||
|
)),
|
||||||
|
user_visibility_cache: Mutex::new(LruCache::new(
|
||||||
|
user_visibility_cache_size,
|
||||||
|
)),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Builds a StateMap by iterating over all keys that start
|
/// Builds a StateMap by iterating over all keys that start
|
||||||
/// with state_hash, this gives the full state for the given state_hash.
|
/// with state_hash, this gives the full state for the given state_hash.
|
||||||
#[tracing::instrument(skip(self))]
|
#[tracing::instrument(skip(self))]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue