Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libsql: add periodic background sync #995

Merged
merged 1 commit into from
Feb 7, 2024
Merged

Conversation

LucioFranco
Copy link
Contributor

This adds a new periodic sync configuration item to the Builder that will allow users to set a duration at which they want the background sync to sync.

@LucioFranco LucioFranco requested a review from penberg February 6, 2024 15:26
Comment on lines +131 to +145
let jh = tokio::spawn(
async move {
loop {
if let Err(e) = replicator2.sync_oneshot().await {
tracing::error!("replicator sync error: {}", e);
}

tokio::time::sleep(sync_duration).await;
}
}
.instrument(tracing::info_span!("periodic_sync")),
);

replicator.bg_abort = Some(Arc::new(DropAbort(jh.abort_handle())));
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would it make sense to spawn this task in a join set instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is an option, I think the behavior is the same here just saves us some code. So maybe we can refactor to that in the future.

This adds a new periodic sync configuration item to the `Builder` that
will allow users to set a duration at which they want the background
sync to sync.
@MarinPostma MarinPostma added this pull request to the merge queue Feb 7, 2024
Merged via the queue into main with commit c18caa4 Feb 7, 2024
12 checks passed
@MarinPostma MarinPostma deleted the lucio/periodic-sync branch February 7, 2024 08:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants