reliar-store-postgres 0.9.0

PostgreSQL provider for the Reliar transactional outbox and inbox: migrations, migrate(), enqueue and the SKIP LOCKED claim.
Documentation
//! `enqueue`'s one statement.

/// [`insert_outbox_row`]'s bind parameters — already encoded for binding (the `MetadataRest`/
/// `headers` JSON building and the "empty remainder is SQL NULL" decision are the store layer's
/// own policy, in `outbox_store_enqueue`, and happen before this struct is built).
pub(in crate::outbox) struct InsertOutboxRowParams<'a> {
    pub(in crate::outbox) message_id: uuid::Uuid,

    pub(in crate::outbox) message_type: &'a str,

    pub(in crate::outbox) message_version: i32,

    pub(in crate::outbox) correlation_id: Option<&'a str>,

    pub(in crate::outbox) conversation_id: uuid::Uuid,

    pub(in crate::outbox) causation_id: Option<uuid::Uuid>,

    pub(in crate::outbox) request_id: Option<uuid::Uuid>,

    pub(in crate::outbox) content_type: &'a str,

    pub(in crate::outbox) payload: &'a [u8],

    pub(in crate::outbox) tenant_id: Option<&'a str>,

    pub(in crate::outbox) expires_at: Option<time::OffsetDateTime>,

    pub(in crate::outbox) ordering_key: Option<&'a str>,

    pub(in crate::outbox) metadata: Option<serde_json::Value>,

    pub(in crate::outbox) headers: Option<serde_json::Value>,
}

/// `enqueue`'s `INSERT`. Omits `id`: the surrogate row identity fires from `DEFAULT uuidv7()`
/// (ADR 0044 §1) — no caller needs it before the row is read back, so nothing here mints or
/// binds one.
pub(in crate::outbox) async fn insert_outbox_row(
    executor: &mut sqlx::PgConnection,
    params: InsertOutboxRowParams<'_>,
) -> Result<(), sqlx::Error> {
    sqlx::query!(
        r#"INSERT INTO outbox (
             message_id, message_type, message_version,
             correlation_id, conversation_id, causation_id, request_id,
             content_type, payload, tenant_id, expires_at, ordering_key,
             metadata, headers, available_at
           ) VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14, now())"#,
        params.message_id,
        params.message_type,
        params.message_version,
        params.correlation_id,
        params.conversation_id,
        params.causation_id,
        params.request_id,
        params.content_type,
        params.payload,
        params.tenant_id,
        params.expires_at,
        params.ordering_key,
        params.metadata,
        params.headers,
    )
    .execute(executor)
    .await?;

    Ok(())
}