pub struct DeadLetter;Expand description
The service’s own DeadLetter: set by
InboxSpec::own.
§Examples
use ruststream_sqlx::dialect::Column;
use ruststream_sqlx::spec::{Payload, own};
use ruststream_sqlx::{DeadLetter, InboxSpec, InboxTable};
use sqlx::{PgConnection, Postgres};
#[derive(sqlx::FromRow)]
pub struct Charge {
id: i64,
payload: Vec<u8>,
}
impl InboxTable for Charge {
type Id = i64;
type Table = InboxSpec<(Payload, own::DeadLetter)>;
const TABLE: Self::Table = InboxSpec::new("charges", Column::new("id").generated())
.payload(Column::new("payload"))
.own::<own::DeadLetter>();
fn id(&self) -> &i64 {
&self.id
}
}
// Every queue of the service parks its spent rows in one `dead_letters` table.
impl DeadLetter<Postgres> for Charge {
async fn dead_letter(
conn: &mut PgConnection,
id: &i64,
destination: &str,
) -> Result<(), sqlx::Error> {
sqlx::query(
"WITH dead AS (DELETE FROM charges WHERE id = $1 RETURNING payload) \
INSERT INTO dead_letters (source, destination, payload) \
SELECT 'charges', $2, payload FROM dead",
)
.bind(id)
.bind(destination)
.execute(conn)
.await?;
Ok(())
}
}Trait Implementations§
Source§impl Debug for DeadLetter
impl Debug for DeadLetter
Source§impl Declaration for DeadLetter
impl Declaration for DeadLetter
Source§type RetryAfter = Unset
type RetryAfter = Unset
The time a retried row is due:
RetryAfter.Source§type ProcessedAt = Unset
type ProcessedAt = Unset
The time a row was processed:
ProcessedAt.Source§type Opening = Unset
type Opening = Unset
What the table’s transactions open at:
Opens; unset for the database’s
default.Source§type OwnClaim = Unset
type OwnClaim = Unset
The service’s own claim:
own::Claim.Source§type OwnFetch = Unset
type OwnFetch = Unset
The service’s own fetch:
own::Fetch.Source§type OwnRetry = Unset
type OwnRetry = Unset
The service’s own retry:
own::Retry.Source§type OwnRetryAfter = Unset
type OwnRetryAfter = Unset
The service’s own delayed retry:
own::RetryAfter.Source§type OwnDiscard = Unset
type OwnDiscard = Unset
The service’s own discard:
own::Discard.Source§type OwnDeadLetter = Set<DeadLetter>
type OwnDeadLetter = Set<DeadLetter>
The service’s own dead letter:
own::DeadLetter.Source§type OwnExtend = Unset
type OwnExtend = Unset
The service’s own lease extension:
own::Extend.Source§type OwnUnlock = Unset
type OwnUnlock = Unset
The service’s own unlock:
own::Unlock.impl OwnEvent for DeadLetter
Auto Trait Implementations§
impl Freeze for DeadLetter
impl RefUnwindSafe for DeadLetter
impl Send for DeadLetter
impl Sync for DeadLetter
impl Unpin for DeadLetter
impl UnsafeUnpin for DeadLetter
impl UnwindSafe for DeadLetter
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
Source§impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
Source§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
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