pub struct LaminarDB { /* private fields */ }Expand description
The main LaminarDB database handle.
Provides a unified interface for SQL execution, data ingestion, and result consumption. All streaming infrastructure (sources, sinks, channels, subscriptions) is managed internally.
Implementations§
Source§impl LaminarDB
impl LaminarDB
Sourcepub fn open() -> Result<Self, DbError>
pub fn open() -> Result<Self, DbError>
Create an embedded in-memory database with default settings.
§Errors
Returns DbError if DataFusion context creation fails.
Sourcepub fn open_with_config(config: LaminarConfig) -> Result<Self, DbError>
pub fn open_with_config(config: LaminarConfig) -> Result<Self, DbError>
Sourcepub async fn adopt_assignment_snapshot(&self, snapshot: AssignmentSnapshot)
pub async fn adopt_assignment_snapshot(&self, snapshot: AssignmentSnapshot)
Adopt a new assignment snapshot: update the registry, backend fence, and coordinator under the coordinator mutex so the change lands strictly between checkpoints. Idempotent for versions at or below the current registry version.
Sourcepub fn session_context(&self) -> &SessionContext
pub fn session_context(&self) -> &SessionContext
Underlying DataFusion SessionContext. Primarily for tests
that need to compile SQL through the same session the engine
uses.
Sourcepub fn builder() -> LaminarDbBuilder
pub fn builder() -> LaminarDbBuilder
Get a fluent builder for constructing a LaminarDB.
Sourcepub fn connector_registry(&self) -> &ConnectorRegistry
pub fn connector_registry(&self) -> &ConnectorRegistry
Returns the connector registry for registering custom connectors.
Use this to register user-defined source/sink connectors before
calling start().
Sourcepub async fn register_delta_table(
&self,
name: &str,
table_uri: &str,
storage_options: HashMap<String, String>,
) -> Result<(), DbError>
pub async fn register_delta_table( &self, name: &str, table_uri: &str, storage_options: HashMap<String, String>, ) -> Result<(), DbError>
Registers a Delta Lake table as a DataFusion TableProvider.
After registration, the table can be queried via SQL:
SELECT * FROM my_delta_table WHERE id > 100§Arguments
name- SQL table name (e.g.,"trades")table_uri- Path to the Delta Lake table (local,s3://,az://,gs://)storage_options- Storage credentials and configuration
§Errors
Returns DbError if the table cannot be opened or registered.
Sourcepub async fn execute(&self, sql: &str) -> Result<ExecuteResult, DbError>
pub async fn execute(&self, sql: &str) -> Result<ExecuteResult, DbError>
Execute a SQL statement.
Supports:
CREATE SOURCE/CREATE SINK— registers sources and sinksDROP SOURCE/DROP SINK— removes sources and sinksSHOW SOURCES/SHOW SINKS/SHOW QUERIES— list registered objectsDESCRIBE source_name— show source schemaSELECT ...— execute a streaming queryINSERT INTO source_name VALUES (...)— insert dataCREATE MATERIALIZED VIEW— create a streaming materialized viewEXPLAIN SELECT ...— show query plan
§Errors
Returns DbError if SQL parsing, planning, or execution fails.
Sourcepub fn get_session_property(&self, key: &str) -> Option<String>
pub fn get_session_property(&self, key: &str) -> Option<String>
Get a session property value.
Sourcepub fn session_properties(&self) -> HashMap<String, String>
pub fn session_properties(&self) -> HashMap<String, String>
Get all session properties.
Sourcepub fn subscribe<T: FromBatch>(
&self,
name: &str,
) -> Result<TypedSubscription<T>, DbError>
pub fn subscribe<T: FromBatch>( &self, name: &str, ) -> Result<TypedSubscription<T>, DbError>
Subscribe to a named stream or materialized view.
§Errors
Returns DbError::StreamNotFound if the stream is not registered.
Sourcepub fn subscribe_raw(
&self,
name: &str,
) -> Result<Subscription<ArrowRecord>, DbError>
pub fn subscribe_raw( &self, name: &str, ) -> Result<Subscription<ArrowRecord>, DbError>
Subscribe to a named stream’s output.
§Errors
Returns DbError::StreamNotFound if the stream doesn’t exist.
Sourcepub fn source<T: Record>(&self, name: &str) -> Result<SourceHandle<T>, DbError>
pub fn source<T: Record>(&self, name: &str) -> Result<SourceHandle<T>, DbError>
Get a typed source handle for pushing data.
The source must have been created via CREATE SOURCE.
§Errors
Returns DbError::SourceNotFound if the source is not registered.
Returns DbError::SchemaMismatch if the Rust type’s schema does not
match the source’s SQL schema.
Sourcepub fn source_untyped(&self, name: &str) -> Result<UntypedSourceHandle, DbError>
pub fn source_untyped(&self, name: &str) -> Result<UntypedSourceHandle, DbError>
Get an untyped source handle for pushing RecordBatch data.
§Errors
Returns DbError::SourceNotFound if the source is not registered.
Sourcepub fn sources(&self) -> Vec<SourceInfo>
pub fn sources(&self) -> Vec<SourceInfo>
List all registered sources.
Sourcepub fn streams(&self) -> Vec<StreamInfo>
pub fn streams(&self) -> Vec<StreamInfo>
List all registered streams with their SQL definitions.
Sourcepub fn pipeline_topology(&self) -> PipelineTopology
pub fn pipeline_topology(&self) -> PipelineTopology
Build the pipeline topology graph from registered sources, streams, and sinks.
Returns a PipelineTopology with nodes for every source, stream,
and sink, plus edges derived from stream SQL FROM references and
sink input fields.
Sourcepub fn is_checkpoint_enabled(&self) -> bool
pub fn is_checkpoint_enabled(&self) -> bool
Returns whether streaming checkpointing is enabled.
Sourcepub fn checkpoint_store(&self) -> Option<Box<dyn CheckpointStore>>
pub fn checkpoint_store(&self) -> Option<Box<dyn CheckpointStore>>
Returns a checkpoint store instance, if checkpointing is configured.
Returns an ObjectStoreCheckpointStore
when object_store_url is set, otherwise a
FileSystemCheckpointStore.
Sourcepub async fn checkpoint(&self) -> Result<CheckpointResult, DbError>
pub async fn checkpoint(&self) -> Result<CheckpointResult, DbError>
Triggers a streaming checkpoint that persists source offsets, sink
positions, and operator state to disk via the
CheckpointCoordinator.
Returns the checkpoint result on success, including the checkpoint ID, epoch, and duration.
§Errors
Returns DbError::Checkpoint if checkpointing is not enabled, the
coordinator has not been initialized (call start() first), or the
checkpoint operation fails.
Sourcepub async fn checkpoint_stats(&self) -> Option<CheckpointStats>
pub async fn checkpoint_stats(&self) -> Option<CheckpointStats>
Returns checkpoint performance statistics.
Returns None if the checkpoint coordinator has not been initialized.
Source§impl LaminarDB
impl LaminarDB
Sourcepub fn set_engine_metrics(&self, metrics: Arc<EngineMetrics>)
pub fn set_engine_metrics(&self, metrics: Arc<EngineMetrics>)
Inject prometheus engine metrics. Called once at startup before start().
Sourcepub fn set_prometheus_registry(&self, registry: Arc<Registry>)
pub fn set_prometheus_registry(&self, registry: Arc<Registry>)
Inject a shared Prometheus registry for connector-level metrics.
Called once at startup, after the registry is constructed but before
start(). Connectors created after this call will register their
metrics on this registry so they appear in the scrape output.
Sourcepub fn engine_metrics(&self) -> Option<Arc<EngineMetrics>>
pub fn engine_metrics(&self) -> Option<Arc<EngineMetrics>>
Get the engine metrics if set.
Sourcepub fn pipeline_state(&self) -> &'static str
pub fn pipeline_state(&self) -> &'static str
Get the current pipeline state as a string.
Sourcepub fn metrics(&self) -> PipelineMetrics
pub fn metrics(&self) -> PipelineMetrics
Get a pipeline-wide metrics snapshot.
Reads prometheus engine metrics and catalog sizes to produce a point-in-time view of pipeline health.
Sourcepub fn source_metrics(&self, name: &str) -> Option<SourceMetrics>
pub fn source_metrics(&self, name: &str) -> Option<SourceMetrics>
Get metrics for a single source by name.
Sourcepub fn all_source_metrics(&self) -> Vec<SourceMetrics>
pub fn all_source_metrics(&self) -> Vec<SourceMetrics>
Get metrics for all registered sources.
Sourcepub fn stream_metrics(&self, name: &str) -> Option<StreamMetrics>
pub fn stream_metrics(&self, name: &str) -> Option<StreamMetrics>
Get metrics for a single stream by name.
Sourcepub fn all_stream_metrics(&self) -> Vec<StreamMetrics>
pub fn all_stream_metrics(&self) -> Vec<StreamMetrics>
Get metrics for all registered streams.
Sourcepub fn total_events_processed(&self) -> u64
pub fn total_events_processed(&self) -> u64
Get the total number of events processed (ingested + emitted).
Sourcepub fn pipeline_watermark(&self) -> i64
pub fn pipeline_watermark(&self) -> i64
Returns the global pipeline watermark (minimum across all source watermarks).
Returns i64::MIN if no watermark-enabled sources exist or no events
have been processed.
Sourcepub fn cancel_query(&self, query_id: u64) -> Result<(), DbError>
pub fn cancel_query(&self, query_id: u64) -> Result<(), DbError>
Cancel a running query by ID.
Marks the query as inactive in the catalog. Future subscription polls for this query will receive no more data.
§Errors
Returns DbError if the query is not found.
Sourcepub fn source_count(&self) -> usize
pub fn source_count(&self) -> usize
Get the number of registered sources.
Sourcepub fn sink_count(&self) -> usize
pub fn sink_count(&self) -> usize
Get the number of registered sinks.
Sourcepub fn checkpoint_stats_nonblocking(&self) -> Option<CheckpointStats>
pub fn checkpoint_stats_nonblocking(&self) -> Option<CheckpointStats>
Returns checkpoint statistics if available (non-blocking).
Uses try_lock() on the coordinator mutex. Returns None if
the coordinator is not initialized or the lock is contended.
Sourcepub fn active_query_count(&self) -> usize
pub fn active_query_count(&self) -> usize
Get the number of active queries.
Source§impl LaminarDB
impl LaminarDB
Sourcepub async fn start(&self) -> Result<(), DbError>
pub async fn start(&self) -> Result<(), DbError>
Start the streaming pipeline.
Activates all registered connectors and begins processing. This is a no-op if the pipeline is already running.
When the kafka feature is enabled and Kafka sources/sinks are
registered, this builds KafkaSource/KafkaSink instances and
spawns a background task that polls sources, executes stream queries
via DataFusion, and writes results to sinks.
In embedded (in-memory) mode, this simply transitions to Running.
§Errors
Returns an error if the pipeline cannot be started. On failure, the
instance is unwound back to STATE_CREATED so the caller can retry
after fixing the offending config.
Sourcepub async fn shutdown(&self) -> Result<(), DbError>
pub async fn shutdown(&self) -> Result<(), DbError>
Shut down the streaming pipeline gracefully.
Signals the processing loop to stop, waits for it to complete
(with a timeout), then transitions to Stopped.
This is idempotent – calling it multiple times is safe.
§Errors
Returns an error if shutdown encounters an error.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for LaminarDB
impl !RefUnwindSafe for LaminarDB
impl Send for LaminarDB
impl Sync for LaminarDB
impl Unpin for LaminarDB
impl UnsafeUnpin for LaminarDB
impl !UnwindSafe for LaminarDB
Blanket Implementations§
§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
§impl<U> As for U
impl<U> As for U
§fn as_<T>(self) -> Twhere
T: CastFrom<U>,
fn as_<T>(self) -> Twhere
T: CastFrom<U>,
self to type T. The semantics of numeric casting with the as operator are followed, so <T as As>::as_::<U> can be used in the same way as T as U for numeric conversions. Read more§impl<T> AsAny for T
impl<T> AsAny for T
§fn any_ref(&self) -> &(dyn Any + Sync + Send + 'static)
fn any_ref(&self) -> &(dyn Any + Sync + Send + 'static)
dyn Any reference to the object: Read more§fn as_any(self: Arc<T>) -> Arc<dyn Any + Sync + Send>
fn as_any(self: Arc<T>) -> Arc<dyn Any + Sync + Send>
Arc<dyn Any> reference to the object: Read more§fn into_any(self: Box<T>) -> Box<dyn Any + Sync + Send>
fn into_any(self: Box<T>) -> Box<dyn Any + Sync + Send>
Box<dyn Any>: Read more§fn type_name(&self) -> &'static str
fn type_name(&self) -> &'static str
std::any::type_name, since Any does not provide it and
Any::type_id is useless as a debugging aid (its Debug is just a mess of hex digits).Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Conv for T
impl<T> Conv for T
§impl<T> Downcast for Twhere
T: AsAny + ?Sized,
impl<T> Downcast for Twhere
T: AsAny + ?Sized,
§fn downcast_ref<T>(&self) -> Option<&T>where
T: AsAny,
fn downcast_ref<T>(&self) -> Option<&T>where
T: AsAny,
Any.§fn downcast_mut<T>(&mut self) -> Option<&mut T>where
T: AsAny,
fn downcast_mut<T>(&mut self) -> Option<&mut T>where
T: AsAny,
Any.§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2where
T: SharedNiching<N1, N2>,
N1: Niching<T>,
N2: Niching<T>,
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2where
T: SharedNiching<N1, N2>,
N1: Niching<T>,
N2: Niching<T>,
§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> Pointee for T
impl<T> Pointee for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§impl<T> Scope for T
impl<T> Scope for T
§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.