reifydb_core/interface/
subscription.rs1use std::sync::Arc;
5
6use crate::interface::catalog::{id::SubscriptionId, shape::ShapeId};
7
8#[derive(Debug, Clone)]
9pub struct SubscriptionWatermarkRow {
10 pub subscription_id: SubscriptionId,
11
12 pub shape_id: ShapeId,
13
14 pub lag: u64,
15}
16
17#[derive(Clone)]
18pub struct SubscriptionWatermarkSampler {
19 fetch: Arc<dyn Fn() -> Vec<SubscriptionWatermarkRow> + Send + Sync>,
20}
21
22impl SubscriptionWatermarkSampler {
23 pub fn new<F>(fetch: F) -> Self
24 where
25 F: Fn() -> Vec<SubscriptionWatermarkRow> + Send + Sync + 'static,
26 {
27 Self {
28 fetch: Arc::new(fetch),
29 }
30 }
31
32 pub fn all(&self) -> Vec<SubscriptionWatermarkRow> {
33 (self.fetch)()
34 }
35}