pub trait ObjectLockManager: Send + Sync {
// Required methods
fn has_meta(&self, hash: SequenceHash) -> BoxFuture<'static, Result<bool>>;
fn try_acquire_lock(
&self,
hash: SequenceHash,
) -> BoxFuture<'static, Result<bool>>;
fn create_meta(&self, hash: SequenceHash) -> BoxFuture<'static, Result<()>>;
fn release_lock(&self, hash: SequenceHash) -> BoxFuture<'static, Result<()>>;
}Expand description
Object lock manager trait for distributed locking in object storage.
This trait provides the locking semantics for the object offload pipeline:
- Check
.metafile to see if block is already offloaded - Try to acquire
.lockfile with conditional PUT - Create
.metafile after successful offload - Release
.lockfile after completion
§Locking Flow
has_meta() -> false -> try_acquire_lock() -> true -> execute transfer -> create_meta() -> release_lock()
-> false -> skip (another instance owns it)
-> true -> skip (already offloaded)Required Methods§
Sourcefn has_meta(&self, hash: SequenceHash) -> BoxFuture<'static, Result<bool>>
fn has_meta(&self, hash: SequenceHash) -> BoxFuture<'static, Result<bool>>
Check if meta file exists (block already offloaded).
Returns true if {hash}.meta exists, meaning the block has been
successfully offloaded and should be skipped.
Sourcefn try_acquire_lock(
&self,
hash: SequenceHash,
) -> BoxFuture<'static, Result<bool>>
fn try_acquire_lock( &self, hash: SequenceHash, ) -> BoxFuture<'static, Result<bool>>
Try to acquire a lock for the given block.
This method:
- Attempts conditional PUT of
{hash}.lockwithIf-None-Match: * - If lock exists, reads it to check deadline
- If deadline is breached (> timeout), overwrites the lock
Returns:
Ok(true)if lock was acquired or overwrittenOk(false)if another instance owns a valid lockErr(...)for other errors
Sourcefn create_meta(&self, hash: SequenceHash) -> BoxFuture<'static, Result<()>>
fn create_meta(&self, hash: SequenceHash) -> BoxFuture<'static, Result<()>>
Create the meta file after successful offload.
This marks the block as successfully offloaded by creating {hash}.meta.
Sourcefn release_lock(&self, hash: SequenceHash) -> BoxFuture<'static, Result<()>>
fn release_lock(&self, hash: SequenceHash) -> BoxFuture<'static, Result<()>>
Release the lock by deleting the lock file.
Deletes {hash}.lock after the transfer is complete.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".