Skip to main content

reifydb_core/interface/
flow.rs

1// SPDX-License-Identifier: Apache-2.0
2// Copyright (c) 2025 ReifyDB
3
4use std::sync::Arc;
5
6use crate::interface::catalog::{flow::FlowId, shape::ShapeId};
7
8#[derive(Debug, Clone)]
9pub struct FlowWatermarkRow {
10	pub flow_id: FlowId,
11
12	pub shape_id: ShapeId,
13
14	pub lag: u64,
15}
16
17#[derive(Clone)]
18pub struct FlowWatermarkSampler {
19	fetch: Arc<dyn Fn() -> Vec<FlowWatermarkRow> + Send + Sync>,
20}
21
22impl FlowWatermarkSampler {
23	pub fn new<F>(fetch: F) -> Self
24	where
25		F: Fn() -> Vec<FlowWatermarkRow> + Send + Sync + 'static,
26	{
27		Self {
28			fetch: Arc::new(fetch),
29		}
30	}
31
32	pub fn all(&self) -> Vec<FlowWatermarkRow> {
33		(self.fetch)()
34	}
35}