Skip to main content

ruststream_sqlx/
prelude.rs

1//! The one glob a service on the inbox imports: the framework's prelude and the inbox's own names.
2//!
3//! # Examples
4//!
5//! ```
6//! # #[cfg(feature = "postgres")]
7//! # mod demo {
8//! use ruststream_sqlx::prelude::*;
9//! use sqlx::PgPool;
10//!
11//! #[derive(Inbox, sqlx::FromRow)]
12//! #[inbox(table = "jobs")]
13//! pub struct Job {
14//!     #[field(id)]
15//!     id: i64,
16//!     #[field(attempt)]
17//!     attempt: i16,
18//!     #[field(payload)]
19//!     payload: Vec<u8>,
20//! }
21//!
22//! #[derive(serde::Deserialize)]
23//! struct Task {
24//!     n: u32,
25//! }
26//!
27//! #[subscriber(InboxQueue::<Job>::new("tasks"))]
28//! async fn run(task: &Task, Ctx(attempt): Ctx<keys::Attempt>) -> HandlerOutcome {
29//!     tracing::info!(task.n, ?attempt, "running");
30//!     HandlerOutcome::ack()
31//! }
32//!
33//! pub fn app(pool: PgPool) -> RustStream {
34//!     RustStream::new(AppInfo::new("worker", "0.1.0")).with_broker(SqlxBroker::new(pool), |b| {
35//!         b.include(run);
36//!     })
37//! }
38//! # }
39//! # fn main() {}
40//! ```
41
42pub use ruststream::prelude::*;
43
44pub use crate::{
45    Inbox, InboxHeaders, InboxQueue, InboxSettings, InboxThreads, Insert, Publish, Repository,
46    Routed, SqlxBroker, keys,
47};