reifydb_core/interface/flow.rs
1// SPDX-License-Identifier: AGPL-3.0-or-later
2// Copyright (c) 2025 ReifyDB
3
4//! Flow lag tracking interface for virtual table support.
5
6use crate::interface::catalog::{flow::FlowId, primitive::PrimitiveId};
7
8/// A row in the system.flow_lags virtual table.
9#[derive(Debug, Clone)]
10pub struct FlowLagRow {
11 /// The flow ID.
12 pub flow_id: FlowId,
13 /// The primitive this flow subscribes to.
14 pub primitive_id: PrimitiveId,
15 /// The lag: how many versions behind the flow is for this source.
16 pub lag: u64,
17}
18
19/// Trait for providing flow lag data to virtual tables.
20///
21/// This trait is defined in the core crate to allow the engine crate
22/// to use it without depending on the sub-flow crate.
23///
24/// Implemented by `FlowLagsProvider` in the sub-flow crate.
25/// Used by the `FlowLags` virtual table in the engine crate.
26pub trait FlowLagsProvider: Send + Sync {
27 /// Get all flow lag rows.
28 ///
29 /// Returns one row per (flow, source) pair, showing how far behind
30 /// each flow is for each of its subscribed sources.
31 fn all_lags(&self) -> Vec<FlowLagRow>;
32}