Skip to main content

awa_model/
lib.rs

1pub mod adapter;
2pub mod admin;
3pub mod batch_operations;
4pub mod bridge;
5pub mod callback_contract;
6pub mod cron;
7pub mod dlq;
8pub mod error;
9pub mod insert;
10pub mod job;
11pub mod kind;
12pub mod migrations;
13pub mod queue_fanout;
14pub mod queue_storage;
15pub mod storage;
16pub mod unique;
17
18// Re-exports for ergonomics
19pub use adapter::postgres::{prepare_job_insert, prepare_raw_job_insert, PreparedJobInsert};
20pub use admin::{
21    CallbackConfig, DefaultAction, JobKindDescriptor, JobKindOverview, ListJobsFilter,
22    QueueDescriptor, QueueOverview, QueueRuntimeConfigSnapshot, QueueRuntimeMode,
23    QueueRuntimeSnapshot, QueueRuntimeSummary, RateLimitSnapshot, ResolveOutcome, RuntimeInstance,
24    RuntimeOverview, RuntimeSnapshotInput, StateTimeseriesBucket, StorageCapability,
25};
26pub use batch_operations::{
27    BatchOperation, BatchOperationFilter, BatchOperationKind, BatchOperationPreview,
28    BatchOperationSpec, BatchOperationState, ListBatchOperationsFilter, SubmitBatchOperation,
29};
30
31/// Deprecated alias preserved for one release so existing downstream code
32/// compiling against `awa_model::QueueStats` keeps building. New callers
33/// should use [`QueueOverview`] directly — the renamed type carries
34/// additional descriptor fields this alias predates.
35#[deprecated(since = "0.5.4", note = "use `QueueOverview` instead")]
36pub type QueueStats = QueueOverview;
37pub use cron::{CronJobRow, CronMissedFirePolicy, PeriodicJob, PeriodicJobBuilder};
38pub use dlq::{DlqMetadata, DlqRow, ListDlqFilter, RetryFromDlqOpts};
39pub use error::{map_sqlx_error, AwaError};
40pub use insert::{insert, insert_many, insert_many_copy, insert_many_copy_from_pool, insert_with};
41pub use job::{InsertOpts, InsertParams, JobRow, JobState, UniqueOpts};
42pub use queue_fanout::{QueueFanout, QueueFanoutError};
43pub use queue_storage::{
44    ClaimedEntry, ClaimedRuntimeJob, PruneOutcome, QueueCounts, QueueStorage, QueueStorageConfig,
45    RotateOutcome, SkipReason, TerminalDeltaRollupOutcome,
46};
47pub use storage::StorageStatus;
48
49// Re-export the derive macro
50pub use awa_macros::JobArgs;
51
52/// Trait for typed job arguments.
53///
54/// Implement this trait (or use `#[derive(JobArgs)]`) to define a job type.
55/// The `kind()` method returns the snake_case kind string that identifies
56/// this job type across languages.
57pub trait JobArgs: serde::Serialize {
58    /// The kind string for this job type (e.g., "send_email").
59    fn kind() -> &'static str
60    where
61        Self: Sized;
62
63    /// Get the kind string for an instance.
64    fn kind_str(&self) -> &'static str
65    where
66        Self: Sized,
67    {
68        Self::kind()
69    }
70
71    /// Serialize to JSON value.
72    fn to_args(&self) -> Result<serde_json::Value, serde_json::Error> {
73        serde_json::to_value(self)
74    }
75}