Skip to main content

LiveOperationGuard

Struct LiveOperationGuard 

Source
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

Source

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.

Source

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.

Source

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.

Source

pub fn owner(&self) -> &LiveOwnershipRow

Source

pub fn claim_key(&self) -> &str

Source

pub fn database_key(&self) -> &str

Source

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.

Source

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.

Source

pub async fn clear_previous_write_values(&self)

Source

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.

Source

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.

Source

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

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

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 more
§

impl<T> IntoRequest<T> for T

§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
§

impl<L> LayerExt<L> for L

§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in [Layered].
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more