laminar_core/lib.rs
1//! # `LaminarDB` Core
2//!
3//! The core streaming engine for `LaminarDB`, implementing the Ring 0 (hot path) components.
4//!
5//! This crate provides:
6//! - **Reactor**: Single-threaded event loop with zero allocations
7//! - **Operators**: Streaming operators (map, filter, window, join)
8//! - **State Store**: Lock-free state management with sub-microsecond lookup
9//! - **Time**: Event time processing, watermarks, and timers
10//!
11//! ## Design Principles
12//!
13//! 1. **Zero allocations on hot path** - Uses arena allocators
14//! 2. **No locks on hot path** - SPSC queues, lock-free structures
15//! 3. **Predictable latency** - < 1μs event processing
16//! 4. **CPU cache friendly** - Data structures optimized for cache locality
17//!
18//! ## Example
19//!
20//! ```rust,ignore
21//! use laminar_core::{Reactor, Config};
22//!
23//! let config = Config::default();
24//! let mut reactor = Reactor::new(config)?;
25//!
26//! // Run the event loop
27//! reactor.run()?;
28//! ```
29
30#![deny(missing_docs)]
31#![warn(clippy::all, clippy::pedantic)]
32#![allow(clippy::module_name_repetitions)]
33// Allow unsafe in alloc module for zero-copy optimizations
34#![allow(unsafe_code)]
35
36/// Cross-partition aggregation.
37pub mod aggregation;
38pub mod alloc;
39pub mod budget;
40/// Distributed checkpoint barrier protocol.
41pub mod checkpoint;
42pub mod compiler;
43pub mod dag;
44pub mod detect;
45/// Structured error code registry (`LDB-NNNN`) and Ring 0 hot path error type.
46pub mod error_codes;
47pub mod io_uring;
48/// Lookup table types and predicate pushdown.
49pub mod lookup;
50pub mod mv;
51pub mod numa;
52pub mod operator;
53pub mod reactor;
54/// Shared Arrow IPC serialization for `RecordBatch` ↔ bytes.
55pub mod serialization;
56pub mod state;
57pub mod streaming;
58pub mod subscription;
59pub mod time;
60pub mod tpc;
61
62/// Distributed delta mode (multi-node coordination).
63#[cfg(feature = "delta")]
64pub mod delta;
65
66// Re-export key types
67pub use reactor::{Reactor, ReactorConfig};
68
69/// Result type for laminar-core operations
70pub type Result<T> = std::result::Result<T, Error>;
71
72/// Error types for laminar-core
73#[derive(Debug, thiserror::Error)]
74pub enum Error {
75 /// Reactor-related errors
76 #[error("Reactor error: {0}")]
77 Reactor(#[from] reactor::ReactorError),
78
79 /// State store errors
80 #[error("State error: {0}")]
81 State(#[from] state::StateError),
82
83 /// Operator errors
84 #[error("Operator error: {0}")]
85 Operator(#[from] operator::OperatorError),
86
87 /// Time-related errors
88 #[error("Time error: {0}")]
89 Time(#[from] time::TimeError),
90
91 /// Thread-per-core runtime errors
92 #[error("TPC error: {0}")]
93 Tpc(#[from] tpc::TpcError),
94
95 /// `io_uring` errors
96 #[error("io_uring error: {0}")]
97 IoUring(#[from] io_uring::IoUringError),
98
99 /// NUMA errors
100 #[error("NUMA error: {0}")]
101 Numa(#[from] numa::NumaError),
102
103 /// Materialized view errors
104 #[error("MV error: {0}")]
105 Mv(#[from] mv::MvError),
106
107 /// DAG topology errors
108 #[error("DAG error: {0}")]
109 Dag(#[from] dag::DagError),
110}