1
0
mirror of https://github.com/matrix-org/matrix-authentication-service.git synced 2025-08-06 06:02:40 +03:00

Add an ActivityTracker which tracks session activity and regularly flush them to the database

This commit is contained in:
Quentin Gliech
2023-09-19 17:10:09 +02:00
parent 16962b451b
commit cf5510a1a2
9 changed files with 563 additions and 12 deletions

View File

@@ -19,7 +19,8 @@ use clap::Parser;
use itertools::Itertools;
use mas_config::AppConfig;
use mas_handlers::{
AppState, CookieManager, HttpClientFactory, MatrixHomeserver, MetadataCache, SiteConfig,
ActivityTracker, AppState, CookieManager, HttpClientFactory, MatrixHomeserver, MetadataCache,
SiteConfig,
};
use mas_listener::{server::Server, shutdown::ShutdownStream};
use mas_matrix_synapse::SynapseConnection;
@@ -140,11 +141,13 @@ impl Options {
compat_token_ttl: config.experimental.compat_token_ttl,
};
let activity_tracker = ActivityTracker::new(pool.clone(), Duration::from_secs(60 * 5));
// Explicitly the config to properly zeroize secret keys
drop(config);
// Listen for SIGHUP
register_sighup(&templates)?;
register_sighup(&templates, &activity_tracker)?;
let graphql_schema = mas_handlers::graphql_schema(&pool, &policy_factory, conn);
@@ -163,6 +166,7 @@ impl Options {
http_client_factory,
password_manager,
site_config,
activity_tracker,
conn_acquisition_histogram: None,
};
s.init_metrics()?;
@@ -242,6 +246,8 @@ impl Options {
mas_listener::server::run_servers(servers, shutdown).await;
state.activity_tracker.shutdown().await;
Ok(())
}
}