Skip to main content

awa_model/
lib.rs

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