pub struct ReservationService { /* private fields */ }Expand description
The verbs. Stateless over a pool; each verb runs in one transaction with the ambient org scope relayed (the module’s uniform posture).
Implementations§
Source§impl ReservationService
impl ReservationService
pub fn new(pool: PgPool) -> Self
Sourcepub async fn hold(
&self,
ref_type: &str,
ref_id: Uuid,
warehouse_id: Uuid,
lines: &[HoldLine],
expires_at: DateTime<Utc>,
) -> Result<Vec<HoldAckLine>, ReservationError>
pub async fn hold( &self, ref_type: &str, ref_id: Uuid, warehouse_id: Uuid, lines: &[HoldLine], expires_at: DateTime<Utc>, ) -> Result<Vec<HoldAckLine>, ReservationError>
Hold lines for ref at warehouse until expires_at. Idempotent
per (ref, item): existing held lines for the ref are replaced. Every
line must fit the fresh availability triangle minus held
reservations, or the whole hold refuses (all-or-nothing).
Sourcepub async fn release(
&self,
ref_type: &str,
ref_id: Uuid,
) -> Result<usize, ReservationError>
pub async fn release( &self, ref_type: &str, ref_id: Uuid, ) -> Result<usize, ReservationError>
Release the ref’s held lines (the cart-close hook). Idempotent.
Sourcepub async fn consume(
&self,
ref_type: &str,
ref_id: Uuid,
) -> Result<usize, ReservationError>
pub async fn consume( &self, ref_type: &str, ref_id: Uuid, ) -> Result<usize, ReservationError>
Consume the ref’s held lines (the order-confirm bridge: the real move’s reservation takes over). Idempotent.
Sourcepub async fn held_for_ref(
&self,
ref_type: &str,
ref_id: Uuid,
) -> Result<Vec<HeldReservation>, ReservationError>
pub async fn held_for_ref( &self, ref_type: &str, ref_id: Uuid, ) -> Result<Vec<HeldReservation>, ReservationError>
The ref’s held lines (inspect).
Sourcepub async fn sweep_expired(&self, limit: i64) -> Result<usize, ReservationError>
pub async fn sweep_expired(&self, limit: i64) -> Result<usize, ReservationError>
The expiry sweep — the abandonment policy. Bounded batches; the caller (a host job pass) loops until it answers zero.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for ReservationService
impl !UnwindSafe for ReservationService
impl Freeze for ReservationService
impl Send for ReservationService
impl Sync for ReservationService
impl Unpin for ReservationService
impl UnsafeUnpin for ReservationService
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
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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> ⓘ
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 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> ⓘ
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