Skip to main content

laminar_db/
lib.rs

1//! Unified database facade for `LaminarDB`.
2//!
3//! Provides a single entry point (`LaminarDB`) that ties together
4//! the SQL parser, query planner, `DataFusion` context, and streaming API.
5//!
6//! # Example
7//!
8//! ```rust,ignore
9//! use laminar_db::LaminarDB;
10//!
11//! let db = LaminarDB::open()?;
12//!
13//! db.execute("CREATE SOURCE trades (
14//!     symbol VARCHAR, price DOUBLE, ts TIMESTAMP,
15//!     WATERMARK FOR ts AS ts - INTERVAL '1' SECOND
16//! )").await?;
17//!
18//! let query = db.execute("SELECT symbol, AVG(price)
19//!     FROM trades GROUP BY symbol, TUMBLE(ts, INTERVAL '1' MINUTE)
20//! ").await?;
21//! ```
22
23#![deny(missing_docs)]
24#![warn(clippy::all, clippy::pedantic)]
25#![allow(clippy::duration_suboptimal_units)] // MSRV 1.85; from_mins/from_hours are 1.91+
26#![allow(clippy::module_name_repetitions)]
27#![allow(clippy::too_many_arguments, clippy::too_many_lines)] // Lifecycle protocols remain contiguous and keep fencing inputs explicit.
28#![allow(clippy::disallowed_types)] // Control-plane maps mirror persisted and cross-crate checkpoint types.
29#![allow(clippy::unused_self)]
30// Feature stubs preserve shared protocol call sites.
31// Lifecycle fixtures favor explicit protocol setup and boundary assertions.
32#![cfg_attr(
33    test,
34    allow(
35        clippy::assertions_on_constants,
36        clippy::default_trait_access,
37        clippy::field_reassign_with_default,
38        clippy::filter_map_bool_then,
39        clippy::float_cmp,
40        clippy::items_after_statements,
41        clippy::manual_let_else,
42        clippy::match_wildcard_for_single_variants,
43        clippy::needless_borrow,
44        clippy::needless_pass_by_value,
45        clippy::needless_return,
46        clippy::redundant_closure,
47        clippy::similar_names,
48        clippy::single_char_pattern,
49        clippy::type_complexity,
50        clippy::unchecked_time_subtraction,
51        clippy::unnecessary_to_owned,
52        clippy::unnecessary_wraps,
53        clippy::unnested_or_patterns,
54        clippy::used_underscore_binding
55    )
56)]
57
58mod aggregate_state;
59/// AI inference module, containing model registry, provider trait, and backends.
60pub mod ai;
61mod ai_catalog;
62mod ai_worker;
63mod builder;
64mod catalog;
65mod catalog_connector;
66mod changelog_filter;
67/// Unified checkpoint coordination.
68#[doc(hidden)]
69pub mod checkpoint_coordinator;
70/// Bounded process-local evidence for cluster checkpoint barrier pauses.
71#[cfg(feature = "cluster")]
72pub mod checkpoint_timing;
73mod config;
74mod connector_manager;
75mod connector_task_fence;
76#[cfg(feature = "cluster")]
77mod coordinated_recovery;
78mod core_window_state;
79mod db;
80/// Prometheus metrics for the streaming engine.
81pub mod engine_metrics;
82// Reopened `impl LaminarDB` modules — split from db.rs
83/// FFI-friendly API for language bindings.
84///
85/// Enable with the `api` feature flag:
86/// ```toml
87/// laminar-db = { version = "0.1", features = ["api"] }
88/// ```
89///
90/// This module provides thread-safe types with numeric error codes,
91/// explicit resource management, and Arrow RecordBatch at all boundaries.
92#[cfg(feature = "api")]
93pub mod api;
94mod ddl;
95mod error;
96mod filter_compile;
97mod handle;
98mod interval_join;
99mod key_column;
100mod log_throttle;
101mod metrics;
102mod metrics_api;
103mod mv_store;
104mod operator;
105mod operator_graph;
106/// Thread-per-core connector pipeline.
107pub mod pipeline;
108mod pipeline_callback;
109mod pipeline_identity;
110mod pipeline_lifecycle;
111/// Deployment profiles.
112pub mod profile;
113/// Dynamic vnode rebalance control plane.
114#[cfg(feature = "cluster")]
115pub mod rebalance;
116/// Unified recovery manager.
117pub mod recovery_manager;
118mod show_commands;
119mod sink_task;
120mod sql_analysis;
121mod sql_utils;
122/// External named-subscription substrate: byte-bounded shared logs and cursor portals.
123pub mod subscription;
124mod table_provider;
125mod table_rows;
126mod table_store;
127mod temporal_join_state;
128#[cfg(test)]
129mod temporal_test_source;
130#[cfg(feature = "cluster")]
131mod vnode_transition_staging;
132
133// End-to-end tests for the crypto-sentiment demo pipeline, backed by wiremock.
134// In-crate (not tests/) so it can drive the OperatorGraph directly.
135#[cfg(test)]
136mod e2e_crypto_sentiment;
137
138/// C FFI layer for LaminarDB.
139///
140/// Enable with the `ffi` feature flag:
141/// ```toml
142/// laminar-db = { version = "0.1", features = ["ffi"] }
143/// ```
144///
145/// This module provides `extern "C"` functions for calling LaminarDB from C
146/// and any language with C FFI support (Python, Java, Node.js, .NET, etc.).
147#[cfg(feature = "ffi")]
148pub mod ffi;
149
150pub use builder::LaminarDbBuilder;
151pub use catalog::{ArrowRecord, SourceCatalog, SourceEntry};
152pub use checkpoint_coordinator::{
153    CheckpointFailureDisposition, CheckpointPhase, CheckpointResult, CheckpointStats,
154};
155pub use config::{
156    BackpressurePolicy, LaminarConfig, RestartPolicy, DEFAULT_MAX_MANAGED_STATE_BYTES,
157};
158pub use db::LaminarDB;
159pub use engine_metrics::EngineMetrics;
160pub use error::DbError;
161pub use handle::{
162    DdlInfo, ExecuteResult, FromBatch, MaterializedViewInfo, PipelineEdge, PipelineNode,
163    PipelineNodeType, PipelineTopology, QueryHandle, QueryInfo, SinkInfo, SourceHandle, SourceInfo,
164    StreamInfo, SubscriptionError, TypedSubscription, TypedSubscriptionEnvelope,
165    TypedSubscriptionFrame, UntypedSourceHandle,
166};
167pub use laminar_connectors::connector::DeliveryGuarantee;
168pub use metrics::{PipelineMetrics, PipelineState, SourceMetrics, StreamMetrics};
169pub use profile::{Profile, ProfileError};
170pub use recovery_manager::{RecoveredState, RecoveryManager};
171pub use subscription::ClusterSubscriptionError;
172
173/// Criterion-only access to the real committed cluster-subscription gateway.
174#[cfg(feature = "benchmark-internals")]
175#[doc(hidden)]
176pub use subscription::cluster::benchmark::{
177    ClusterSubscriptionGatewayBenchmark, GatewayReplayObservation, SlowReaderFootprint,
178};
179
180/// Cluster assignment lifecycle results.
181#[cfg(feature = "cluster")]
182pub use db::{ClusterStartupDisposition, SnapshotAdoption};
183
184/// Re-export the connector registry for custom connector registration.
185pub use laminar_connectors::registry::ConnectorRegistry;
186
187/// Re-export connector metadata types for the control-plane HTTP API
188/// (connector catalog / source-creation wizard).
189pub use laminar_connectors::config::{ConfigKeySpec, ConnectorInfo};