Skip to main content

TenantDovecote

Struct TenantDovecote 

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

PostgreSQL Dovecote operations restricted to one validated tenant.

Implementations§

Source§

impl TenantDovecote

Source

pub const fn tenant_id(&self) -> &TenantId

Returns this handle’s validated tenant identifier.

Source

pub const fn pool(&self) -> &PgPool

Borrows the pool used by this handle.

Source

pub async fn bind_tenant<'c>( &self, transaction: &mut Transaction<'c, Postgres>, ) -> Result<(), Error>

Binds this tenant to a transaction for the optional PostgreSQL RLS profile. Adapter predicates remain active even without RLS.

§Errors

Returns the database error if binding transaction-local tenant context fails. The caller must roll back the transaction before retrying.

Source

pub async fn enqueue<'c>( &self, transaction: &mut Transaction<'c, Postgres>, event: NewEvent, ) -> Result<EnqueueOutcome, EnqueueError>

Enqueues an event for this tenant in the caller-owned transaction.

§Errors

Returns an identity conflict for different immutable content, a schema or backend incompatibility, invalid stored data, or a database error. The caller must roll back its transaction on failure; this method never commits it.

Source

pub async fn import_for_migration<'c>( &self, transaction: &mut Transaction<'c, Postgres>, event: NewEvent, state: ImportedDeliveryState, ) -> Result<ImportOutcome, ImportError>

Imports one event and legacy state for this tenant.

§Errors

Returns a conflict if existing immutable content or delivery history differs, or an error for unsupported history, incompatible schema, invalid stored data, or database failure. Roll back the caller-owned transaction on failure.

Source

pub async fn finalize_pending_delivery_for_migration<'c>( &self, transaction: &mut Transaction<'c, Postgres>, row_id: RowId, delivered_at: OffsetDateTime, ) -> Result<FinalizeOutcome, FinalizeError>

Finalizes one canonical pending migration row for this tenant.

§Errors

Returns an error for invalid occurrence time, conflicting or non-pending delivery history, incompatible schema, or database failure. The caller owns rollback and commit; a failed operation must not be committed.

Source

pub async fn page( &self, after_row_id: Option<RowId>, limit: Limit, ) -> Result<Vec<PagedEvent>, PageError>

Reads a live page restricted to this tenant.

§Errors

Returns an error for incompatible schema, invalid stored event or delivery state, or a database failure. No delivery state is changed.

Source

pub async fn begin_snapshot(&self) -> Result<SnapshotPager, PageError>

Begins a finite snapshot pager restricted to this tenant.

§Errors

Returns an error if the backend cannot establish the required snapshot, the schema is incompatible, or a database operation fails.

Source

pub async fn claim( &self, worker: WorkerId, lease_for: Lease, limit: Limit, ) -> Result<Vec<ClaimedEvent>, ClaimError>

Claims pending and expired deliveries for this tenant.

§Errors

Returns an error for incompatible backend or schema, invalid stored state, attempt-counter overflow, unavailable entropy, or database failure. The owned transaction is rolled back on pre-commit failure; an unknown commit requires recovery from durable state rather than assuming no claim occurred.

Source

pub async fn renew( &self, row_id: RowId, claim_token: &ClaimToken, lease_for: Lease, ) -> Result<(), MutationError>

Renews one current claim for this tenant.

§Errors

Returns LostClaim if the token no longer owns an unexpired claim, or an error for invalid stored state, duration overflow, or database failure.

Source

pub async fn ack( &self, row_id: RowId, claim_token: &ClaimToken, ) -> Result<(), MutationError>

Acknowledges one current claim for this tenant.

§Errors

Returns LostClaim if the token no longer owns an unexpired claim, or an error for invalid stored state or database failure. A lost commit response requires durable-state recovery; delivery remains at least once.

Source

pub async fn retry( &self, row_id: RowId, claim_token: &ClaimToken, failure: &Failure, backoff: Delay, ) -> Result<(), MutationError>

Returns one current claim to pending for this tenant.

§Errors

Returns LostClaim if the token no longer owns an unexpired claim, or an error for invalid stored state, delay overflow, or database failure.

Source

pub async fn release( &self, row_id: RowId, claim_token: &ClaimToken, delay: Delay, ) -> Result<(), MutationError>

Releases one current claim for this tenant.

§Errors

Returns LostClaim if the token no longer owns an unexpired claim, or an error for invalid stored state, delay overflow, or database failure.

Source

pub async fn quarantine( &self, row_id: RowId, claim_token: &ClaimToken, reason: &QuarantineReason, ) -> Result<(), MutationError>

Quarantines one current claim for this tenant.

§Errors

Returns LostClaim if the token no longer owns an unexpired claim, or an error for invalid stored state or database failure.

Trait Implementations§

Source§

impl Clone for TenantDovecote

Source§

fn clone(&self) -> TenantDovecote

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> 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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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