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