pub struct Syncer { /* private fields */ }Expand description
Holds the registered SyncSources and runs them against a
MirrorStore.
Implementations§
Source§impl Syncer
impl Syncer
Sourcepub fn new(store: MirrorStore) -> Self
pub fn new(store: MirrorStore) -> Self
Build a syncer with the LastWriteWins default strategy.
Sourcepub fn with_strategy(
store: MirrorStore,
strategy: Arc<dyn ConflictStrategy>,
) -> Self
pub fn with_strategy( store: MirrorStore, strategy: Arc<dyn ConflictStrategy>, ) -> Self
Build a syncer with a custom conflict strategy.
Sourcepub fn register_source(&mut self, source: Arc<dyn SyncSource>)
pub fn register_source(&mut self, source: Arc<dyn SyncSource>)
Register a source so it can be referenced by id later.
Sourcepub fn store(&self) -> &MirrorStore
pub fn store(&self) -> &MirrorStore
Read-only access to the store, e.g. for queries.
Sourcepub async fn sync_source(&self, source_id: &str) -> Result<SyncReport>
pub async fn sync_source(&self, source_id: &str) -> Result<SyncReport>
Sync every batch a source is able to produce in one go. Stops when the
source reports has_more = false or returns an empty batch.
Sourcepub async fn sync_stream(
&self,
source: &dyn SyncSource,
cursor: Option<String>,
) -> Result<u64>
pub async fn sync_stream( &self, source: &dyn SyncSource, cursor: Option<String>, ) -> Result<u64>
Drain a source’s SyncSource::subscribe stream into the store.
Each delta is applied immediately as it arrives. Returns the count of deltas successfully applied. Stops when the stream ends or errors.
Sourcepub async fn sync_with(&self, source: &dyn SyncSource) -> Result<SyncReport>
pub async fn sync_with(&self, source: &dyn SyncSource) -> Result<SyncReport>
Sync a single concrete SyncSource (handy when callers manage their
own registry).
Auto Trait Implementations§
impl Freeze for Syncer
impl !RefUnwindSafe for Syncer
impl Send for Syncer
impl Sync for Syncer
impl Unpin for Syncer
impl UnsafeUnpin for Syncer
impl !UnwindSafe for Syncer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more