pub trait TimeColumn {
type Time: QueueTime;
}Expand description
The type of a field playing a time role: a QueueTime or an Option of one.
§Examples
use chrono::{DateTime, Utc};
use ruststream_sqlx::prelude::*;
use serde::Deserialize;
use sqlx::PgPool;
// `processed_at` is empty until the row is finished; an acknowledgement writes a
// `DateTime<Utc>` into it and the row stays in the table.
#[derive(Inbox, sqlx::FromRow)]
#[inbox(table = "invoice_jobs")]
pub struct InvoiceJob {
#[field(id, generated)]
id: i64,
#[field(processed_at, generated)]
processed_at: Option<DateTime<Utc>>,
#[field(payload)]
payload: Vec<u8>,
}
#[derive(Deserialize)]
struct Invoice {
number: u64,
}
#[subscriber(InboxQueue::<InvoiceJob>::new("invoices"))]
async fn issue(invoice: &Invoice) -> HandlerOutcome {
tracing::info!(invoice.number, "issued");
HandlerOutcome::ack()
}
pub fn app(pool: PgPool) -> RustStream {
RustStream::new(AppInfo::new("billing", "0.1.0")).with_broker(SqlxBroker::new(pool), |b| {
b.include(issue);
})
}Required Associated Types§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".