log/lib.rs
1//! OpenData Log - A key-oriented log system built on SlateDB.
2//!
3//! OpenData Log provides a simple log abstraction where each key represents an
4//! independent log stream. Unlike traditional messaging systems with partitions,
5//! users write directly to keys and can create new keys as access patterns evolve.
6//!
7//! # Architecture
8//!
9//! The log is built on SlateDB's LSM tree. Writes append entries to the WAL and
10//! memtable, then flush to sorted string tables (SSTs). LSM compaction naturally
11//! organizes data for log locality, grouping entries by key prefix over time.
12//!
13//! # Key Concepts
14//!
15//! - **LogDb**: The main entry point providing both read and write operations.
16//! - **LogDbReader**: A read-only view of the log, useful for consumers that should
17//! not have write access.
18//! - **Sequence Numbers**: Each entry is assigned a global sequence number at
19//! append time. Sequence numbers are monotonically increasing within a key's
20//! log but not contiguous (other keys' appends are interleaved).
21//!
22//! # Example
23//!
24//! ```ignore
25//! use log::{LogDb, Config, Record};
26//! use bytes::Bytes;
27//!
28//! // Open a log
29//! let log = LogDb::open(Config::default()).await?;
30//!
31//! // Append records
32//! let records = vec![
33//! Record { key: Bytes::from("orders"), value: Bytes::from("order-123") },
34//! ];
35//! log.append(records).await?;
36//!
37//! // Scan a key's log
38//! let mut iter = log.scan(Bytes::from("orders"), ..);
39//! while let Some(entry) = iter.next().await? {
40//! println!("seq={}, value={:?}", entry.sequence, entry.value);
41//! }
42//! ```
43
44mod config;
45mod delta;
46mod error;
47mod listing;
48mod log;
49mod model;
50mod range;
51mod reader;
52mod segment;
53mod serde;
54#[cfg(feature = "http-server")]
55pub mod server;
56mod storage;
57
58pub use config::{Config, CountOptions, ReaderConfig, ScanOptions, SegmentConfig, WriteOptions};
59pub use error::{Error, Result};
60pub use listing::{LogKey, LogKeyIterator};
61pub use log::{LogDb, LogDbBuilder};
62pub use model::{AppendResult, LogEntry, Record, Segment, SegmentId, Sequence};
63
64pub use reader::{LogDbReader, LogIterator, LogRead};
65
66// Re-export proto types for use by clients
67#[cfg(feature = "http-server")]
68pub mod proto {
69 pub use crate::server::proto::*;
70}