pub const SUBJECT_PREFIX: &str = "photon";
pub const SHARDED_SUBJECT_PREFIX: &str = "photon-s";
pub const STREAM_SUBJECTS: &str = "photon.>";
pub const HEADER_EVENT_ID: &str = "Photon-Event-Id";
pub const HEADER_SEQ: &str = "Photon-Seq";
pub const HEADER_TOPIC_KEY: &str = "Photon-Topic-Key";
#[must_use]
pub fn photon_subject(topic_name: &str) -> String {
format!("{SUBJECT_PREFIX}.{topic_name}")
}
const KV_SEP: &str = "/";
#[must_use]
pub fn checkpoint_key(sub: &str, topic: &str, topic_key: Option<&str>) -> String {
format!(
"{sub}{}{topic}{}{}",
KV_SEP,
KV_SEP,
topic_key.unwrap_or("__null__")
)
}
#[must_use]
pub fn checkpoint_key_sharded(
sub: &str,
topic: &str,
topic_key: Option<&str>,
stream_shard: u32,
) -> String {
format!("{}/s{stream_shard}", checkpoint_key(sub, topic, topic_key))
}
#[must_use]
pub fn checkpoint_key_unkeyed_shards(sub: &str, topic: &str) -> String {
format!("{sub}{KV_SEP}__shards__{topic}")
}