1
0
mirror of https://github.com/matrix-org/matrix-authentication-service.git synced 2025-08-09 04:22:45 +03:00

Add a lock during syncs of user devices

This commit is contained in:
Quentin Gliech
2024-07-15 13:39:58 +02:00
parent 695228ade4
commit 3eab10672f
8 changed files with 96 additions and 3 deletions

View File

@@ -259,6 +259,19 @@ pub trait UserRepository: Send + Sync {
///
/// Returns [`Self::Error`] if the underlying repository fails
async fn count(&mut self, filter: UserFilter<'_>) -> Result<usize, Self::Error>;
/// Acquire a lock on the user to make sure device operations are done in a
/// sequential way. The lock is released when the repository is saved or
/// rolled back.
///
/// # Parameters
///
/// * `user`: The user to lock
///
/// # Errors
///
/// Returns [`Self::Error`] if the underlying repository fails
async fn acquire_lock_for_sync(&mut self, user: &User) -> Result<(), Self::Error>;
}
repository_impl!(UserRepository:
@@ -284,4 +297,5 @@ repository_impl!(UserRepository:
pagination: Pagination,
) -> Result<Page<User>, Self::Error>;
async fn count(&mut self, filter: UserFilter<'_>) -> Result<usize, Self::Error>;
async fn acquire_lock_for_sync(&mut self, user: &User) -> Result<(), Self::Error>;
);