Skip to main content

WalHandle

Struct WalHandle 

Source
pub struct WalHandle { /* private fields */ }
Expand description

Control plane for a running WAL engine.

This handle is intentionally single-owner and not cloneable. Calling enqueue_append through &mut self gives the database one linear admission point for its caller-assigned sequence numbers, while returned AppendCompletion values remain independently awaitable by the database’s apply pipeline.

Implementations§

Source§

impl WalHandle

Source

pub async fn enqueue_append( &mut self, seqno: WalSeqNo, record: Bytes, ) -> Result<AppendCompletion, Error>

Admit one caller-numbered opaque record without waiting for durability.

Before waiting, this method verifies that seqno is exactly the next contiguous sequence number and that the record fits the configured limits. If the manifest has no slot recovery could use to seal this active object, admission returns Error::SegmentDirectoryFull. If the active object is at its hard ceiling, admission returns Error::ActiveSegmentFull. Neither condition consumes seqno; truncation may free directory capacity, after which the same append can be retried. Otherwise this waits for encoded-byte admission capacity and a bounded queue slot. On success the WAL owns the record and the returned AppendCompletion may be moved to another task. Await that completion before applying the transaction to the database.

The payload should be the database’s complete encoded transaction batch. The WAL treats it as opaque bytes and never merges it with another call. Dropping the completion does not cancel admitted work. On an eventual completion error, use Error::may_have_committed before deciding whether recovery must resolve the sequence number.

Source

pub async fn truncate_before( &self, floor: WalSeqNo, ) -> Result<TruncationReport, Error>

Advance the application checkpoint floor and delete eligible sealed segments.

floor is the first record the database still needs. Call this only after the database has durably checkpointed every record before that boundary. The WAL deletes only whole sealed segments; it never truncates the active segment or deletes a segment containing floor.

Deletion is best effort across zones. The returned report contains only deletion statistics; the database remains the authority for the durable checkpoint it supplied. Startup and periodic maintenance retry tombstones whose zones were unavailable during this call. A successful truncation also makes the engine re-read directory capacity, so an active segment held at Error::ActiveSegmentFull can rotate and resume admission once enough entries are removed.

Source

pub async fn abort(self)

Consume the admission handle, abort every owned task, and await their termination.

Accepted completions may resolve as closed or ambiguous. Use shutdown when accepted work must drain gracefully.

Source

pub async fn shutdown(self) -> Result<(), Error>

Consume the admission handle, drain accepted work, finish every committed seal, and wait for all owned tasks to exit.

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.

Source§

impl<T> Instrument for T

Source§

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

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

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> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

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

impl<L> LayerExt<L> for L

Source§

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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
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.
Source§

impl<T> WithSubscriber for T

Source§

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

fn with_current_subscriber(self) -> WithDispatch<Self>

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