pub struct PendingRows(/* private fields */);Expand description
Rows queued on an open transaction for one batched multi-row INSERT at
flush/commit time, instead of one INSERT per write. Cheap to clone — it
shares the same underlying buffer, which matters when a nested
transaction() call reuses its parent’s queue.
Implementations§
Source§impl PendingRows
impl PendingRows
pub fn new() -> Self
Sourcepub async fn push(
&self,
tenant: &TenantId,
project: &ProjectId,
author: &UserTokenClaims,
fhir_version: &SupportedFHIRVersions,
resource: Resource,
deleted: bool,
request_method: &'static str,
fhir_method: FHIRMethod,
)
pub async fn push( &self, tenant: &TenantId, project: &ProjectId, author: &UserTokenClaims, fhir_version: &SupportedFHIRVersions, resource: Resource, deleted: bool, request_method: &'static str, fhir_method: FHIRMethod, )
Buffers a row. Unlike [insert], resource must be an owned copy —
this data has to outlive the call that queued it, until flush runs.
Sourcepub async fn flush(
&self,
tx: &Arc<Mutex<Transaction<'static, Postgres>>>,
) -> Result<(), OperationOutcomeError>
pub async fn flush( &self, tx: &Arc<Mutex<Transaction<'static, Postgres>>>, ) -> Result<(), OperationOutcomeError>
Drains and inserts every buffered row, so a subsequent read on the same transaction observes prior writes that haven’t reached Postgres yet. The internal lock is released before tx is locked, so the two are never held simultaneously.
§Errors
Returns an OperationOutcomeError if inserting the buffered rows
into Postgres fails.
Trait Implementations§
Source§impl Clone for PendingRows
impl Clone for PendingRows
Source§fn clone(&self) -> PendingRows
fn clone(&self) -> PendingRows
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for PendingRows
impl Debug for PendingRows
Source§impl Default for PendingRows
impl Default for PendingRows
Source§fn default() -> PendingRows
fn default() -> PendingRows
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl !RefUnwindSafe for PendingRows
impl !UnwindSafe for PendingRows
impl Freeze for PendingRows
impl Send for PendingRows
impl Sync for PendingRows
impl Unpin for PendingRows
impl UnsafeUnpin for PendingRows
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,
impl<T> ErasedDestructor for Twhere
T: 'static,
§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> ⓘ
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