Skip to main content

ruststream_fred/
prelude.rs

1//! The core prelude plus everything a service mixing all three Redis forms writes.
2//!
3//! The broker, every descriptor and publish policy, the seek types, the per-delivery and
4//! batch contexts with their [`keys`], and the [`crate::stream`], [`crate::list`] and
5//! [`crate::pubsub`] modules.
6//!
7//! # Examples
8//!
9//! ```
10//! # mod demo {
11//! use ruststream_fred::prelude::*;
12//! use serde::{Deserialize, Serialize};
13//!
14//! #[derive(Deserialize)]
15//! struct Order {
16//!     id: u64,
17//! }
18//!
19//! #[derive(Serialize, Outgoing)]
20//! #[outgoing(name = "orders.shipped")]
21//! struct Shipped {
22//!     id: u64,
23//! }
24//!
25//! #[subscriber(RedisStream::new("orders").group("workers"), reply)]
26//! async fn ship(order: &Order) -> Shipped {
27//!     Shipped { id: order.id }
28//! }
29//!
30//! #[subscriber(RedisList::new("invoices").reliable())]
31//! async fn invoice(order: &Order) -> HandlerOutcome {
32//!     println!("invoicing order {}", order.id);
33//!     HandlerOutcome::ack()
34//! }
35//!
36//! #[ruststream::app]
37//! fn app() -> impl App {
38//!     RustStream::new(AppInfo::new("orders", "0.1.0")).with_broker(
39//!         RedisBroker::standalone("redis://localhost:6379"),
40//!         |b| {
41//!             // A stream in, a Pub/Sub broadcast out: the form prefix says which `Publish`.
42//!             b.include(ship).out_reply(pubsub::Publish::default());
43//!             b.include(invoice);
44//!         },
45//!     )
46//! }
47//! # }
48//! # fn main() {}
49//! ```
50//!
51//! A service on a single form globs that form's prelude instead, which carries `Publish` under the
52//! uniform mount-site name and only the capabilities that form has.
53
54pub use ruststream::prelude::*;
55
56// Do not add `Partitioned` here: the core surfaces `partition_key` through `IncomingMessage`'s
57// defaulted method, which this glob already carries, so re-exporting the trait makes the call
58// ambiguous (E0034).
59pub use ruststream::{OwnedTransactions, Positioned, Seeker, Transaction, TransactionalPublisher};
60
61// `keys` arrives as the module, not as a glob: its members are short words a service also uses for
62// its own types, and `Ctx<keys::SeekHandle>` reads as what it is at the use site.
63pub use crate::context::{
64    PipelineContext, PoolContext, PubSubContext, StreamBatchContext, StreamContext, keys,
65};
66
67pub use crate::pipeline::{Bindable, InRound, RedisPipelineSteps};
68
69pub use crate::{
70    DelayedRetry, PARTITION_KEY_HEADER, PubSubMode, RedisBroker, RedisGroupPosition,
71    RedisGroupSeeker, RedisList, RedisListPublish, RedisPubSub, RedisPubSubPattern,
72    RedisPubSubPublish, RedisPublish, RedisPublishOptions, RedisPublishSteps, RedisStream,
73    RedisSubscribeExt, StreamStart,
74};
75
76// The policies keep their prefixed names here, and there is no bare `Publish`: this glob spans all
77// three forms, so the one mount-site word would name three colliding types. A mixed file globs
78// this prelude and writes `stream::Publish` beside `pubsub::Publish` through these modules.
79pub use crate::{list, pubsub, stream};
80
81#[cfg(any(
82    feature = "tls-rustls",
83    feature = "tls-rustls-ring",
84    feature = "tls-native-tls"
85))]
86pub use crate::{TlsConfig, TlsConnector};