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;
57/// Platform-abstracted non-blocking storage I/O for Ring 0.
58pub mod storage_io;
59pub mod streaming;
60pub mod subscription;
61pub mod time;
62pub mod tpc;
63
64/// Distributed delta mode (multi-node coordination).
65#[cfg(feature = "delta")]
66pub mod delta;
67
68// Re-export key types
69pub use reactor::{Reactor, ReactorConfig};
70
71/// Result type for laminar-core operations
72pub type Result<T> = std::result::Result<T, Error>;
73
74/// Error types for laminar-core
75#[derive(Debug, thiserror::Error)]
76pub enum Error {
77 /// Reactor-related errors
78 #[error("Reactor error: {0}")]
79 Reactor(#[from] reactor::ReactorError),
80
81 /// State store errors
82 #[error("State error: {0}")]
83 State(#[from] state::StateError),
84
85 /// Operator errors
86 #[error("Operator error: {0}")]
87 Operator(#[from] operator::OperatorError),
88
89 /// Time-related errors
90 #[error("Time error: {0}")]
91 Time(#[from] time::TimeError),
92
93 /// Thread-per-core runtime errors
94 #[error("TPC error: {0}")]
95 Tpc(#[from] tpc::TpcError),
96
97 /// `io_uring` errors
98 #[error("io_uring error: {0}")]
99 IoUring(#[from] io_uring::IoUringError),
100
101 /// NUMA errors
102 #[error("NUMA error: {0}")]
103 Numa(#[from] numa::NumaError),
104
105 /// Materialized view errors
106 #[error("MV error: {0}")]
107 Mv(#[from] mv::MvError),
108
109 /// DAG topology errors
110 #[error("DAG error: {0}")]
111 Dag(#[from] dag::DagError),
112}