Skip to main content

photon_backend_kafka/
lib.rs

1//! Kafka [`StoragePort`](photon_backend::StoragePort) for distributed Photon delivery.
2//!
3//! Wraps Kafka consumer groups, checkpoint persistence, and topic sharding behind the shared
4//! storage contract. Enable via the `kafka` feature on the
5//! [`photon`](https://docs.rs/uf-photon/latest/photon/) facade.
6//!
7//! Connection and topic options: [`KafkaConfig`] and [`KafkaStoragePortBuilder`]
8//! (builder methods + env fallbacks documented on the builder).
9//!
10//! Wire with [`PhotonBuilder::storage_port`](https://docs.rs/uf-photon/latest/photon/struct.PhotonBuilder.html#method.storage_port)
11//! after [`KafkaStoragePortBuilder::build`](KafkaStoragePortBuilder::build).
12//!
13//! ## Entry points
14//!
15//! - [`KafkaStoragePort`] — Kafka storage adapter
16//! - [`KafkaConfig`] / [`KafkaStoragePortBuilder`] — connection and topic options
17//! - [`kafka_brokers_from_env`] — resolve broker list from environment
18//!
19//! Performance methodology: [`photon-bench/PERFORMANCE_STUDY.md`](../../photon-bench/PERFORMANCE_STUDY.md).
20//!
21//! ## Topic mapping (Kafka)
22//!
23//! - **Topic:** `photon-{topic}` when `topic_shards = 1`; `photon-s-{shard}-{topic}` when sharded.
24//! - **Checkpoints:** compact topic `photon-checkpoints` (same key layout as other broker adapters).
25//! - **Replay:** [`ReplayCursor::StreamSeq`] stores offset+1; [`ReplayCursor::TailOnly`] tails live only.
26
27mod checkpoint;
28mod config;
29mod connect;
30mod consumer;
31mod message;
32mod port;
33mod publish;
34mod replicas;
35mod retention;
36pub mod stream_shard;
37mod subject;
38mod topic;
39
40pub use config::{
41    KafkaConfig, KafkaStoragePortBuilder, ReplayCursor, BROKERS_ENV, MAX_INFLIGHT_ENV,
42    PREFIX_ENV, REPLAY_CURSOR_ENV, SYNC_ACK_ENV,
43};
44pub use consumer::{consumer_group_for, durable_consumer_name};
45pub use port::{kafka_brokers_from_env, KafkaStoragePort};
46pub use replicas::REPLICAS_ENV;
47pub use retention::RETENTION_ENV;
48pub use stream_shard::TOPIC_SHARDS_ENV;