Skip to main content

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
36pub mod alloc;
37pub mod budget;
38pub mod compiler;
39pub mod dag;
40pub mod detect;
41pub mod io_uring;
42pub mod mv;
43pub mod numa;
44pub mod operator;
45pub mod reactor;
46pub mod sink;
47pub mod state;
48pub mod streaming;
49pub mod subscription;
50pub mod time;
51pub mod tpc;
52pub mod xdp;
53
54// Re-export key types
55pub use reactor::{Reactor, ReactorConfig};
56
57/// Result type for laminar-core operations
58pub type Result<T> = std::result::Result<T, Error>;
59
60/// Error types for laminar-core
61#[derive(Debug, thiserror::Error)]
62pub enum Error {
63    /// Reactor-related errors
64    #[error("Reactor error: {0}")]
65    Reactor(#[from] reactor::ReactorError),
66
67    /// State store errors
68    #[error("State error: {0}")]
69    State(#[from] state::StateError),
70
71    /// Operator errors
72    #[error("Operator error: {0}")]
73    Operator(#[from] operator::OperatorError),
74
75    /// Time-related errors
76    #[error("Time error: {0}")]
77    Time(#[from] time::TimeError),
78
79    /// Thread-per-core runtime errors
80    #[error("TPC error: {0}")]
81    Tpc(#[from] tpc::TpcError),
82
83    /// `io_uring` errors
84    #[error("io_uring error: {0}")]
85    IoUring(#[from] io_uring::IoUringError),
86
87    /// NUMA errors
88    #[error("NUMA error: {0}")]
89    Numa(#[from] numa::NumaError),
90
91    /// Sink errors
92    #[error("Sink error: {0}")]
93    Sink(#[from] sink::SinkError),
94
95    /// Materialized view errors
96    #[error("MV error: {0}")]
97    Mv(#[from] mv::MvError),
98
99    /// XDP/eBPF errors
100    #[error("XDP error: {0}")]
101    Xdp(#[from] xdp::XdpError),
102
103    /// DAG topology errors
104    #[error("DAG error: {0}")]
105    Dag(#[from] dag::DagError),
106}