1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
//! The **broker** subsystem (spec section 22).
//!
//! This module contains all the components responsible for accepting
//! published messages, routing them to the correct topic, deduplicating
//! repeated submissions, maintaining per-topic offset cursors, persisting
//! message logs and snapshots, and fanning out live deliveries to
//! connected subscribers.
//!
//! # Architecture
//!
//! The central abstraction is the [`Broker`] trait, which defines the
//! full set of topic-level operations (publish, subscribe, replay, etc.)
//! as async methods. Three concrete implementations are provided:
//!
//! | Implementation | Use case |
//! |---|---|
//! | [`InMemoryBroker`] | Single-process, all storage in memory. Ideal for development and testing. |
//! | [`RemoteBroker`] | Connects to an external broker node over TCP using the [`wire`] protocol. |
//! | [`ActorBroker`] | Each topic is an independent Tokio actor task; publishes to different topics run concurrently. |
//!
//! # Key components
//!
//! - **[`broker`]** — The [`Broker`] trait itself, plus the [`PublishOutcome`] type
//! and the `serialize_frame_for_fanout` helper.
//! - **[`fanout`]** — The [`FanoutEngine`] that delivers serialized frames to all
//! active subscribers of a topic.
//! - **[`dedupe`]** — The [`DedupeStore`] that suppresses duplicate messages within
//! a configurable time window.
//! - **[`router`]** — The [`TopicRouter`] trait and its [`LocalRouter`] implementation
//! that resolves topic names to [`TopicEntry`] handles.
//! - **[`offset_store`]** — A per-topic monotonic offset allocator.
//! - **[`snapshot_store`]** — Captures and retrieves per-topic snapshots.
//! - **[`wire`]** — The framed TCP wire protocol used between gateway and
//! broker nodes.
//! - **[`memory_broker`]** — The generic [`InMemoryBroker`] struct that wires
//! all the above components together.
//! - **[`remote_broker`]** — TCP-based distributed broker client.
//! - **[`actor_broker`]** — Actor-based broker that delegates to a
//! [`TopicRegistry`](crate::actor::TopicRegistry).
//!
//! [`TopicEntry`]: crate::topic::TopicEntry
/// Actor-backed broker implementation that delegates each topic to an
/// independent Tokio actor task.
pub use ActorBroker;
/// The core broker trait and supporting types.
pub use ;
/// Time-window-based message deduplication store.
pub use DedupeStore;
/// Fanout engine, connection sinks, subscription management, and
/// related types.
pub use ;
/// Single-process broker with pluggable storage backends.
pub use InMemoryBroker;
/// Per-topic monotonic offset allocator.
pub use OffsetStore;
/// TCP-based remote broker client.
pub use RemoteBroker;
/// Topic routing layer (local and future distributed).
pub use ;
/// Snapshot persistence types.
pub use ;