Skip to content

Commit

Permalink
feat: add run method
Browse files Browse the repository at this point in the history
  • Loading branch information
hydra-yse committed Nov 18, 2024
1 parent f2fe0f6 commit 13f510c
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions lib/core/src/sync/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
use std::collections::HashMap;
use std::sync::Arc;
use std::time::Duration;

use anyhow::{anyhow, Result};
use futures_util::TryFutureExt;

use crate::sync::model::sync::{Record, SetRecordRequest, SetRecordStatus};
use crate::utils;
Expand Down Expand Up @@ -52,6 +54,21 @@ impl SyncService {
}
}

async fn run(self: Arc<Self>) -> Result<()> {
let cloned = self.clone();

tokio::spawn(async move {
loop {
if let Err(err) = cloned.pull().and_then(|_| cloned.push()).await {
log::debug!("Could not run sync event loop: {err:?}");
}
tokio::time::sleep(Duration::from_secs(30)).await;
}
});

Ok(())
}

fn commit_record(
&self,
decrypted_record: &DecryptedRecord,
Expand Down

0 comments on commit 13f510c

Please sign in to comment.