pub struct RealIndexLock { /* private fields */ }Expand description
What:
A real index.lock created by this process.
Why:
Holding the identity lets the release prove the file is still the one created.
In TS you’d write (pseudocode):
type RealIndexLock = { lockPath: string; identity: LockIdentity; installIndex(source): Promise<void> };Implementations§
Source§impl RealIndexLock
impl RealIndexLock
Sourcepub fn identity(&self) -> &LockIdentity
pub fn identity(&self) -> &LockIdentity
What: The identity recorded for the lock. Why: The landing journal stores it.
In TS you’d write (pseudocode):
lock.identitySourcepub fn assert_identity(&self) -> Result<(), String>
pub fn assert_identity(&self) -> Result<(), String>
What: Whether the lock path still names the file this process created. Why: A release or install must not act on a replaced lock.
In TS you’d write (pseudocode):
await assertLockIdentity({ lockPath, identity });Sourcepub fn release(self) -> Result<(), String>
pub fn release(self) -> Result<(), String>
What: Release the lock and this process’s PID file, refusing a lock that was replaced. Why: A replaced lock belongs to another process and stays in place.
In TS you’d write (pseudocode):
await lock[Symbol.asyncDispose]();Sourcepub fn install(self, post_index: &Path) -> Result<(), RecoveryError>
pub fn install(self, post_index: &Path) -> Result<(), RecoveryError>
What:
Install a computed index through the held lock,
consuming the lock,
then remove this process’s PID file.
Why:
installIndex:
the bytes are written into the lock this process created,
the lock is linked under a private name beside the post-index,
and that name is renamed over the real index,
so the new index keeps the lock’s owner.
The lock is not released here on failure:
once the landing record is durable,
recovery completes the install through the same lock.
In TS you’d write (pseudocode):
await lock.installIndex(postIndexPath);Sourcepub fn release_after_landing(self) -> Result<(), String>
pub fn release_after_landing(self) -> Result<(), String>
What: Release a lock a landing leaves without installing: the lock is removed only while it is still the file this process created, and the PID file goes either way. Why: The incumbent’s disposal warns when the lock is gone or another owner’s now and still removes its own PID file, and throws only for an operating-system error.
In TS you’d write (pseudocode):
await lock[Symbol.asyncDispose]();Trait Implementations§
Source§impl Debug for RealIndexLock
impl Debug for RealIndexLock
impl Eq for RealIndexLock
Source§impl PartialEq for RealIndexLock
impl PartialEq for RealIndexLock
impl StructuralPartialEq for RealIndexLock
Auto Trait Implementations§
impl Freeze for RealIndexLock
impl RefUnwindSafe for RealIndexLock
impl Send for RealIndexLock
impl Sync for RealIndexLock
impl Unpin for RealIndexLock
impl UnsafeUnpin for RealIndexLock
impl UnwindSafe for RealIndexLock
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
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.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> ⓘ
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> ⓘ
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 more