1
0
mirror of https://github.com/matrix-org/matrix-authentication-service.git synced 2025-11-20 12:02:22 +03:00

Test the activity tracker on the introspection endpoint

This commit is contained in:
Quentin Gliech
2023-09-19 19:50:42 +02:00
parent 50558a7319
commit 894957934d
4 changed files with 53 additions and 5 deletions

View File

@@ -52,7 +52,7 @@ enum Message {
date_time: DateTime<Utc>,
ip: Option<IpAddr>,
},
Flush,
Flush(tokio::sync::oneshot::Sender<()>),
Shutdown(tokio::sync::oneshot::Sender<()>),
}
@@ -150,10 +150,18 @@ impl ActivityTracker {
/// Manually flush the activity tracker.
pub async fn flush(&self) {
let res = self.channel.send(Message::Flush).await;
let (tx, rx) = tokio::sync::oneshot::channel();
let res = self.channel.send(Message::Flush(tx)).await;
if let Err(e) = res {
tracing::error!("Failed to flush activity tracker: {}", e);
match res {
Ok(_) => {
if let Err(e) = rx.await {
tracing::error!("Failed to flush activity tracker: {}", e);
}
}
Err(e) => {
tracing::error!("Failed to flush activity tracker: {}", e);
}
}
}