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 asof_batch;
64mod builder;
65mod catalog;
66mod catalog_connector;
67mod changelog_filter;
68/// Unified checkpoint coordination.
69#[doc(hidden)]
70pub mod checkpoint_coordinator;
71#[cfg(feature = "cluster")]
72mod cluster_recovery_capsule;
73mod config;
74mod connector_manager;
75mod connector_task_fence;
76mod coordinated_committer;
77#[cfg(feature = "cluster")]
78mod coordinated_recovery;
79mod core_window_state;
80mod db;
81/// Prometheus metrics for the streaming engine.
82pub mod engine_metrics;
83mod eowc_state;
84// Reopened `impl LaminarDB` modules — split from db.rs
85/// FFI-friendly API for language bindings.
86///
87/// Enable with the `api` feature flag:
88/// ```toml
89/// laminar-db = { version = "0.1", features = ["api"] }
90/// ```
91///
92/// This module provides thread-safe types with numeric error codes,
93/// explicit resource management, and Arrow RecordBatch at all boundaries.
94#[cfg(feature = "api")]
95pub mod api;
96mod ddl;
97mod error;
98mod filter_compile;
99mod handle;
100mod interval_join;
101mod key_column;
102mod log_throttle;
103mod metrics;
104mod metrics_api;
105mod mv_store;
106mod operator;
107mod operator_graph;
108/// Thread-per-core connector pipeline.
109pub mod pipeline;
110mod pipeline_callback;
111mod pipeline_identity;
112mod pipeline_lifecycle;
113/// Deployment profiles.
114pub mod profile;
115/// Dynamic vnode rebalance control plane.
116#[cfg(feature = "cluster")]
117pub mod rebalance;
118/// Unified recovery manager.
119pub mod recovery_manager;
120mod retractable_accumulator;
121mod show_commands;
122mod sink_task;
123mod sql_analysis;
124mod sql_utils;
125/// External named-subscription substrate: byte-bounded shared logs and cursor portals.
126pub mod subscription;
127mod table_backend;
128mod table_provider;
129mod table_store;
130mod temporal_probe;
131mod vnode_partial;
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::{BackpressurePolicy, LaminarConfig, RestartPolicy};
156pub use db::LaminarDB;
157pub use engine_metrics::EngineMetrics;
158pub use error::DbError;
159pub use handle::{
160    DdlInfo, ExecuteResult, FromBatch, MaterializedViewInfo, PipelineEdge, PipelineNode,
161    PipelineNodeType, PipelineTopology, QueryHandle, QueryInfo, SinkInfo, SourceHandle, SourceInfo,
162    StreamInfo, SubscriptionError, TypedSubscription, TypedSubscriptionFrame, UntypedSourceHandle,
163};
164pub use laminar_connectors::connector::DeliveryGuarantee;
165pub use metrics::{PipelineMetrics, PipelineState, SourceMetrics, StreamMetrics};
166pub use profile::{Profile, ProfileError};
167pub use recovery_manager::{RecoveredState, RecoveryManager, VnodeRehydration, VnodeRehydrator};
168
169/// Rebalance-driven state-rehydration types (cluster mode).
170#[cfg(feature = "cluster")]
171pub use db::{ClusterStartupDisposition, RehydratedVnode, SnapshotAdoption};
172
173/// Re-export the connector registry for custom connector registration.
174pub use laminar_connectors::registry::ConnectorRegistry;
175
176/// Re-export connector metadata types for the control-plane HTTP API
177/// (connector catalog / source-creation wizard).
178pub use laminar_connectors::config::{ConfigKeySpec, ConnectorInfo};