Rindle docs and package mapSkip to main content

SessionEngine

Struct SessionEngine 

pub struct SessionEngine<C, R> { /* private fields */ }
Expand description

The shared session engine: owns session metadata + the parked queue + id minting + the deadline; drives a SessionBackend for everything that touches the transaction. Generic over the server’s parked one-shot command C and its deferred responder R.

Implementations§

§

impl<C, R> SessionEngine<C, R>

pub fn new(session_deadline: Duration) -> SessionEngine<C, R>

pub fn with_id_prefix( session_deadline: Duration, prefix: impl Into<String>, ) -> SessionEngine<C, R>

Construct an engine whose session ids are namespaced by prefix (for example ms3-). Only the id spelling changes; scheduling, deadlines, and wire replies are identical.

pub fn session_open(&self) -> bool

Whether a session currently holds the writer — the server’s loop checks this to park one-shot writes instead of running them.

pub fn owns_session(&self, session_id: &str) -> bool

Whether this engine owns the named open session. Pooled dispatchers use this for connection affinity; callers learn nothing about the backend transaction itself.

pub fn has_public_terminal(&self, session_id: &str, operation_id: &str) -> bool

Whether this engine retained the terminal reply for a completed public commit operation. The pooled dispatcher uses this to route a response-loss retry back to the connection that produced the original answer even though the transaction itself is already closed.

pub fn wait(&self) -> Option<Duration>

How long the loop may sleep before the open session’s deadline (recv_timeout bound); None when no session is open (block on recv as usual).

pub fn park_one_shot(&mut self, cmd: C)

Park a one-shot server command while a session is open (the caller checked session_open). Deferred — no thread is held — and the server’s admission cap bounds the queue (every parked command still owns its inflight slot).

pub fn take_parked_for_reopen(&mut self) -> Option<SessionEngine<C, R>>

Move only the admitted FIFO into a fresh engine generation. A host that must replace its storage engine between two one-shots uses this while no session is open: queued responders retain their order, while session ids and terminal-reply caches remain generation-scoped and are deliberately reset just as they are on an ordinary restart.

pub fn expire_if_due(&mut self, be: &mut impl SessionBackend) -> Option<String>

Expire the open session if its deadline passed: RAII rollback via the backend. Returns the dead session’s id for the server to log (each server has its own log prefix); the caller then runs its drain pump. Called from the loop’s timeout wake AND before each command, so expiry cannot be starved by unrelated traffic.

pub fn deadline(&self) -> Duration

The configured deadline (for the server’s expiry log line).

pub fn handle(&mut self, be: &mut impl SessionBackend, op: SessionOp, resp: R)

Route one session op. A begin while a session is open PARKS (FIFO with one-shot writes); everything else resolves against the open session or answers gone. After any call that can close the session (commit/rollback/a poisoning error), the server runs its drain pump (next_parked) — calling it unconditionally is cheap (an open session or empty queue returns Idle immediately).

pub fn next_parked(&mut self, be: &mut impl SessionBackend) -> ParkedNext<C>

The drain pump, run by the server in a loop after session close points: handles parked session ops INTERNALLY in strict FIFO (a parked begin that opens the next session stops the drain; an absorbed/gap/failed one answers and the drain continues), and hands each parked one-shot back for the server to run — returning it (rather than taking a run closure) sidesteps the double-&mut-self borrow a callback would force on servers whose one-shot executor is a method of the struct owning this engine.

pub fn pop_parked_one_shot_if( &mut self, pred: impl FnOnce(&C) -> bool, ) -> Option<C>

Pop the next parked command IF it is a one-shot matching pred — the server’s group-commit fold peek (rindled folds a contiguous parked /execute-sql-txn run into one commit, exactly as a channel backlog would). Never crosses a parked session op.

Auto Trait Implementations§

§

impl<C, R> Freeze for SessionEngine<C, R>

§

impl<C, R> RefUnwindSafe for SessionEngine<C, R>

§

impl<C, R> Send for SessionEngine<C, R>
where C: Send, R: Send,

§

impl<C, R> Sync for SessionEngine<C, R>
where C: Sync, R: Sync,

§

impl<C, R> Unpin for SessionEngine<C, R>
where C: Unpin, R: Unpin,

§

impl<C, R> UnsafeUnpin for SessionEngine<C, R>

§

impl<C, R> UnwindSafe for SessionEngine<C, R>
where C: UnwindSafe, R: UnwindSafe,

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, 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> 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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,