octl_core/ids.rs
1//! Identifier generators and types per design.md ยง1.1.
2
3use ulid::Ulid;
4
5/// Generate a new lowercase-ULID `run_id`.
6pub fn new_run_id() -> String {
7 Ulid::new().to_string().to_lowercase()
8}
9
10/// Generate a new lowercase-ULID operation id, used to name a single
11/// crash-recoverable transaction (e.g. one `run merge` attempt's
12/// [`MergeTxn`](crate::MergeTxn)). Monotonic and collision-free, so recovery can
13/// name exactly which transaction it resolved.
14pub fn new_op_id() -> String {
15 Ulid::new().to_string().to_lowercase()
16}
17
18/// Format a monotonic per-run `node_id` (e.g. `n-0001`).
19pub fn format_node_id(n: u32) -> String {
20 format!("n-{n:04}")
21}