pub struct LiveOperationGuard { /* private fields */ }Expand description
A held OS lock paired with the conditional SQLite owner/claim and an independent
five-second heartbeat. Dropping it releases the OS lock; successful completion must call
Self::release so the database owner and claim are also durably retired.
Implementations§
Source§impl LiveOperationGuard
impl LiveOperationGuard
Sourcepub async fn acquire(
pool: &SqlitePool,
run_id: Option<i64>,
operation_kind: LiveOperationKind,
bridge_host: &str,
server: &str,
resource_tag: &str,
restore_intent_json: Option<String>,
) -> Result<Self, LiveOwnershipAcquireError>
pub async fn acquire( pool: &SqlitePool, run_id: Option<i64>, operation_kind: LiveOperationKind, bridge_host: &str, server: &str, resource_tag: &str, restore_intent_json: Option<String>, ) -> Result<Self, LiveOwnershipAcquireError>
Acquires the OS lock first, then creates the owner and atomically claims its canonical database/controller/tag key. Recovery uses a separate transaction that also starts the recovery attempt and records its evidence.
Sourcepub async fn acquire_for_recorded_run(
pool: &SqlitePool,
run: &TuneRunRow,
operation_kind: LiveOperationKind,
restore_intent_json: String,
) -> Result<Self, LiveOwnershipAcquireError>
pub async fn acquire_for_recorded_run( pool: &SqlitePool, run: &TuneRunRow, operation_kind: LiveOperationKind, restore_intent_json: String, ) -> Result<Self, LiveOwnershipAcquireError>
Acquires ownership for a post-run write or revert using only the connection and MV
recorded on run. Explicit caller values must be cross-checked before this function;
they are never used to select a different controller.
Sourcepub async fn try_acquire_database_file(
pool: &SqlitePool,
) -> Result<Option<DatabaseFileGuard>>
pub async fn try_acquire_database_file( pool: &SqlitePool, ) -> Result<Option<DatabaseFileGuard>>
Returns a database-file guard without creating a database owner. Full-mode startup uses this to distinguish a stale heartbeat from a still-running, possibly paused owner.
pub fn owner(&self) -> &LiveOwnershipRow
pub fn claim_key(&self) -> &str
pub fn database_key(&self) -> &str
Sourcepub fn ensure_healthy(&self) -> Result<()>
pub fn ensure_healthy(&self) -> Result<()>
Prevents a caller from starting another controller mutation after an asynchronous database-heartbeat failure. An already-issued driver call remains protected by the OS lock until its owning future finishes or the process exits.
Sourcepub async fn queue_previous_write_value(&self, tag: &str, value_json: String)
pub async fn queue_previous_write_value(&self, tag: &str, value_json: String)
Queues the value observed before the next write to tag. The audited driver consumes
it when it records the write intent, preserving correct pre-write data even for
write-and-rollback sequences on the same tag.
pub async fn clear_previous_write_values(&self)
Sourcepub async fn persist_restore_intent(&self, intent_json: &str) -> Result<()>
pub async fn persist_restore_intent(&self, intent_json: &str) -> Result<()>
Replaces the pre-mutation recovery intent with a more complete, durably persisted snapshot. Failure prevents the caller from issuing its next live write.
Sourcepub async fn release(self) -> Result<()>
pub async fn release(self) -> Result<()>
Retires the persisted owner/claim before releasing the OS lock. A database persistence failure is returned to the caller and must never be reported as successful completion.
Sourcepub async fn stop_heartbeat(&mut self)
pub async fn stop_heartbeat(&mut self)
Stops heartbeat updates while a recovery attempt atomically finalizes both owners and the claim. The caller must keep this guard alive until that transaction succeeds or fails.
Trait Implementations§
Source§impl Drop for LiveOperationGuard
impl Drop for LiveOperationGuard
Auto Trait Implementations§
impl !RefUnwindSafe for LiveOperationGuard
impl !UnwindSafe for LiveOperationGuard
impl Freeze for LiveOperationGuard
impl Send for LiveOperationGuard
impl Sync for LiveOperationGuard
impl Unpin for LiveOperationGuard
impl UnsafeUnpin for LiveOperationGuard
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> 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§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].