Skip to main content

krabka_client_streams/barrier/
mod.rs

1//! Barrier cuts: an exact, reproducible point in every input at once.
2//!
3//! A krabka broker injects an epoch-stamped marker into every partition of a
4//! named barrier group and publishes the resulting **cut**, one marker offset
5//! per partition, to the internal topic `__barrier_state`. The marker is a Kafka
6//! control record, so no consumer ever receives one. A task aligns on a cut by
7//! comparing its consumed offsets against the cut's offsets, never by watching
8//! for a marker.
9//!
10//! # Key Types
11//!
12//! - [`BarrierCut`] — one epoch's cut, with the marker offset of each partition.
13//! - [`CutReader`] — reads published cuts from `__barrier_state`.
14//! - [`BarrierAlignment`] — tells a runtime which group to align on, and where
15//!   to keep each cut's snapshot.
16//! - [`BarrierListener`] — the callback that fires when a barrier is reached.
17//!
18//! # Examples
19//!
20//! ```no_run
21//! use std::sync::Arc;
22//!
23//! use krabka_client_streams::{barrier::BarrierAlignment, store::snapshot::FileSnapshotStore};
24//!
25//! # fn build() -> BarrierAlignment {
26//! let snapshots = Arc::new(FileSnapshotStore::new("/var/lib/app/state"));
27//! BarrierAlignment::on("transactions", snapshots)
28//! # }
29//! ```
30
31mod align;
32mod cut;
33mod reader;
34#[cfg(test)]
35pub(crate) mod testing;
36
37pub use align::{Barrier, BarrierAlignment, BarrierListener};
38pub use cut::{BARRIER_STATE_TOPIC, BarrierCut, CutStatus, decode_barrier_cut};
39pub use reader::CutReader;