pub struct LockingService { /* private fields */ }Expand description
Service for managing file editing locks.
Implementations§
Source§impl LockingService
impl LockingService
pub fn new( lock_repo: Arc<FileLockRepository>, file_repo: Arc<StoredFileRepository>, ) -> Self
Sourcepub async fn acquire_lock(
&self,
file_id: Uuid,
user_id: Uuid,
duration_minutes: Option<i64>,
) -> ServiceResult<FileLock>
pub async fn acquire_lock( &self, file_id: Uuid, user_id: Uuid, duration_minutes: Option<i64>, ) -> ServiceResult<FileLock>
Acquire an editing lock on a file.
If the file is already locked by the same user, refreshes the lock. If locked by another user and the lock is still valid, returns an error. Expired locks are automatically cleaned up.
Sourcepub async fn release_lock(
&self,
file_id: Uuid,
user_id: Uuid,
) -> ServiceResult<()>
pub async fn release_lock( &self, file_id: Uuid, user_id: Uuid, ) -> ServiceResult<()>
Release a lock. Only the lock owner can release it.
Sourcepub async fn refresh_lock(
&self,
file_id: Uuid,
user_id: Uuid,
) -> ServiceResult<FileLock>
pub async fn refresh_lock( &self, file_id: Uuid, user_id: Uuid, ) -> ServiceResult<FileLock>
Refresh an existing lock’s expiry time.
Sourcepub async fn break_lock(&self, file_id: Uuid) -> ServiceResult<()>
pub async fn break_lock(&self, file_id: Uuid) -> ServiceResult<()>
Admin-only: forcibly break a lock regardless of owner.
Sourcepub async fn get_active_lock(
&self,
file_id: Uuid,
) -> ServiceResult<Option<FileLock>>
pub async fn get_active_lock( &self, file_id: Uuid, ) -> ServiceResult<Option<FileLock>>
Get the active (non-expired) lock for a file, if any. Automatically cleans up expired locks.
Sourcepub async fn cleanup_expired(&self) -> ServiceResult<u64>
pub async fn cleanup_expired(&self) -> ServiceResult<u64>
Cleanup all expired locks. Returns the number of locks removed.
Auto Trait Implementations§
impl !RefUnwindSafe for LockingService
impl !UnwindSafe for LockingService
impl Freeze for LockingService
impl Send for LockingService
impl Sync for LockingService
impl Unpin for LockingService
impl UnsafeUnpin for LockingService
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreCreates a shared type from an unshared type.