mirror of
https://github.com/aljazceru/turso.git
synced 2025-12-27 13:04:20 +01:00
add sync server module
This commit is contained in:
46
packages/turso-sync/src/sync_server/mod.rs
Normal file
46
packages/turso-sync/src/sync_server/mod.rs
Normal file
@@ -0,0 +1,46 @@
|
||||
use crate::Result;
|
||||
|
||||
#[cfg(test)]
|
||||
pub mod test;
|
||||
pub mod turso;
|
||||
|
||||
#[derive(Debug, serde::Deserialize)]
|
||||
pub struct DbSyncInfo {
|
||||
pub current_generation: usize,
|
||||
}
|
||||
|
||||
#[derive(Debug, serde::Deserialize)]
|
||||
pub struct DbSyncStatus {
|
||||
pub baton: Option<String>,
|
||||
pub status: String,
|
||||
pub generation: usize,
|
||||
pub max_frame_no: usize,
|
||||
}
|
||||
|
||||
pub trait Stream {
|
||||
fn read_chunk(
|
||||
&mut self,
|
||||
) -> impl std::future::Future<Output = Result<Option<hyper::body::Bytes>>> + Send;
|
||||
}
|
||||
|
||||
pub trait SyncServer {
|
||||
type Stream: Stream;
|
||||
fn db_info(&self) -> impl std::future::Future<Output = Result<DbSyncInfo>> + Send;
|
||||
fn db_export(
|
||||
&self,
|
||||
generation_id: usize,
|
||||
) -> impl std::future::Future<Output = Result<Self::Stream>> + Send;
|
||||
fn wal_pull(
|
||||
&self,
|
||||
generation_id: usize,
|
||||
start_frame: usize,
|
||||
) -> impl std::future::Future<Output = Result<Self::Stream>> + Send;
|
||||
fn wal_push(
|
||||
&self,
|
||||
baton: Option<String>,
|
||||
generation_id: usize,
|
||||
start_frame: usize,
|
||||
end_frame: usize,
|
||||
frames: Vec<u8>,
|
||||
) -> impl std::future::Future<Output = Result<DbSyncStatus>> + Send;
|
||||
}
|
||||
Reference in New Issue
Block a user