use anyhow::Result;
use surreal_sync_core::Row;
use uuid::Uuid;
use super::types::{
PkTuple, ReconciliationEvent, ReconciliationPos, SnapshotSignal, TableSpec, WatermarkKind,
};
#[async_trait::async_trait]
pub trait WatermarkSource: Send {
type Position: ReconciliationPos;
async fn snapshot_tables(&self) -> Result<Vec<TableSpec>>;
async fn read_chunk(
&self,
table: &TableSpec,
after: Option<&PkTuple>,
limit: usize,
) -> Result<Vec<Row>>;
async fn write_watermark(&self, kind: WatermarkKind, id: Uuid) -> Result<()>;
async fn next_reconciliation_events(
&mut self,
) -> Result<Vec<ReconciliationEvent<Self::Position>>>;
async fn current_position(&self) -> Result<Self::Position>;
async fn commit_reconciled(&mut self, position: Self::Position) -> Result<()>;
async fn on_table_snapshot_complete(&mut self, table: &str) -> Result<()> {
let _ = table;
Ok(())
}
async fn read_signals(&mut self) -> Result<Vec<SnapshotSignal>>;
async fn resolve_tables(&self, names: &[String]) -> Result<Vec<TableSpec>>;
}