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