Skip to main content

faucet_source_rabbitmq/
lib.rs

1#![cfg_attr(docsrs, feature(doc_cfg))]
2
3//! # faucet-source-rabbitmq
4//!
5//! A [RabbitMQ](https://www.rabbitmq.com) (AMQP 0.9.1) source for
6//! `faucet-stream`, built on the pure-Rust [`lapin`](https://crates.io/crates/lapin)
7//! client. Consumes a queue (optionally declaring it and its exchange
8//! bindings), drains until `max_messages` or `idle_timeout_secs` fires, and
9//! yields each message body as a record (`json` / `string` / `bytes`).
10//!
11//! With `ack_mode: on_sink_confirm` (the default) a page's deliveries are
12//! acknowledged only after the pipeline has written and flushed that page, so
13//! a crash redelivers rather than loses messages (at-least-once — pair with a
14//! keyed-upsert sink for effectively-once). `ack_mode: auto` is at-most-once.
15//!
16//! ```no_run
17//! use faucet_source_rabbitmq::{RabbitMqSource, RabbitMqSourceConfig};
18//! # async fn ex() -> Result<(), faucet_core::FaucetError> {
19//! let source = RabbitMqSource::new(RabbitMqSourceConfig::new("orders")).await?;
20//! # let _ = source;
21//! # Ok(())
22//! # }
23//! ```
24
25pub mod config;
26pub mod stream;
27
28pub use config::{AckMode, OnDecodeError, RabbitMqBinding, RabbitMqSourceConfig};
29pub use stream::RabbitMqSource;
30
31pub use faucet_common_rabbitmq::{
32    RabbitMqAuth, RabbitMqConnectionConfig, RabbitMqExchangeKind, RabbitMqTls, RabbitMqValueFormat,
33};
34pub use faucet_core::{FaucetError, Source};
35
36/// The connector's static descriptor (RFC 0013): its capabilities, answered from config alone.
37pub const DESCRIPTOR: faucet_core::ConnectorDescriptor =
38    faucet_core::ConnectorDescriptor::new("rabbitmq", faucet_core::capabilities::plain_source);