Skip to main content

awa_model/
adapter.rs

1//! Stable building blocks for external database adapters.
2//!
3//! These APIs let integration crates execute Awa-compatible inserts through
4//! their own Postgres driver or transaction type while reusing Awa's canonical
5//! validation, scheduling, uniqueness, and shard-routing preparation.
6
7/// Postgres adapter helpers.
8pub mod postgres {
9    use crate::insert::POSTGRES_INSERT_JOB_SQL;
10
11    pub use crate::insert::{prepare_job_insert, prepare_raw_job_insert, PreparedJobInsert};
12
13    /// Canonical SQL for inserting one prepared Awa job through a Postgres
14    /// driver that binds state and unique state masks as text.
15    ///
16    /// Bind parameters in the order exposed by [`PreparedJobInsert`]:
17    /// kind, queue, args, state, priority, max_attempts, run_at, metadata,
18    /// tags, unique_key, unique_states, ordering_key.
19    pub const INSERT_JOB_SQL: &str = POSTGRES_INSERT_JOB_SQL;
20
21    /// SQLSTATE for Postgres unique-violation errors.
22    ///
23    /// Adapters should map this to [`crate::AwaError::UniqueConflict`] when
24    /// their driver exposes database error codes.
25    pub const UNIQUE_VIOLATION_SQLSTATE: &str = "23505";
26}