ruststream_lapin/lib.rs
1//! `RabbitMQ` / AMQP 0.9.1 broker for the
2//! [RustStream](https://github.com/powersemmi/ruststream) messaging framework, backed by
3//! [`lapin`].
4//!
5//! # Transport model
6//!
7//! A subscription consumes one queue; [`RabbitQueue`] describes the queue and its bindings, and
8//! the bare-string `#[subscriber("orders")]` form consumes the queue named `orders`. On the
9//! publish side [`OutgoingMessage::name`](ruststream::OutgoingMessage) is the routing key, sent
10//! to the publisher's exchange (the default exchange unless configured, where the routing key
11//! addresses the queue with that name).
12//!
13//! Settlement uses the protocol natively, with no republish tricks:
14//!
15//! - ack sends `basic.ack`
16//! - retry (`nack(true)`) sends `basic.nack` with requeue
17//! - drop (`nack(false)`) sends `basic.reject` without requeue, dead-lettering when the queue
18//! has a dead-letter exchange
19//!
20//! # Lazy startup
21//!
22//! [`LapinBroker::new`] is synchronous and I/O-free, so a service composes with the synchronous
23//! `#[ruststream::app]` builder; the real network work happens in the idempotent async
24//! `Broker::connect`, called once by the runtime at startup. Publishers handed out before that
25//! resolve the shared connection on first use.
26//!
27//! # Topology
28//!
29//! Descriptors describe the EXPECTED topology; nothing is created on the broker by default,
30//! because managing infrastructure is the user's job. Declaration is a per-broker opt-in:
31//! [`LapinBroker::declare_topology`].
32//!
33//! [`lapin`]: https://docs.rs/lapin
34
35#![forbid(unsafe_code)]
36
37mod broker;
38mod convert;
39mod delay;
40mod error;
41mod exchange;
42mod message;
43mod publisher;
44mod queue;
45mod reply;
46mod requester;
47mod subscriber;
48
49pub mod context;
50#[cfg(feature = "testing")]
51pub mod testing;
52
53pub use broker::LapinBroker;
54pub use delay::Delay;
55pub use error::AmqpError;
56pub use exchange::RabbitExchange;
57pub use message::{LapinMessage, PARTITION_KEY_HEADER};
58pub use publisher::{ConfirmsPublisher, LapinPublisher, ServerTxPublisher};
59pub use queue::{QueueType, RabbitQueue};
60pub use reply::DirectReplyTo;
61pub use requester::LapinRequester;
62pub use subscriber::LapinSubscriber;
63
64// Raw declaration-argument passthrough (`RabbitQueue::argument` / `arguments`).
65pub use lapin::types::{AMQPValue, FieldTable};