pub struct ReplicationService<'a> { /* private fields */ }Expand description
Backend-neutral replication operations over a Thingd store.
Implementations§
Source§impl<'a> ReplicationService<'a>
impl<'a> ReplicationService<'a>
Sourcepub fn new(engine: &'a mut dyn ThingStore, config: ReplicationConfig) -> Self
pub fn new(engine: &'a mut dyn ThingStore, config: ReplicationConfig) -> Self
Create a service over an existing in-memory or persistent engine.
Sourcepub const fn config(&self) -> &ReplicationConfig
pub const fn config(&self) -> &ReplicationConfig
Return the service configuration.
Sourcepub fn record_object_upsert(
&mut self,
object: &MemoryObject,
) -> ThingdResult<()>
pub fn record_object_upsert( &mut self, object: &MemoryObject, ) -> ThingdResult<()>
Record an object upsert in the durable source feed.
§Errors
Returns an error if the service is not configured as a source or the durable replication event cannot be appended.
Sourcepub fn record_object_delete(
&mut self,
collection: &str,
id: &str,
) -> ThingdResult<()>
pub fn record_object_delete( &mut self, collection: &str, id: &str, ) -> ThingdResult<()>
Record an object deletion in the durable source feed.
§Errors
Returns an error if the service is not configured as a source or the durable replication event cannot be appended.
Sourcepub fn record_event_append(&mut self, event: &MemoryEvent) -> ThingdResult<()>
pub fn record_event_append(&mut self, event: &MemoryEvent) -> ThingdResult<()>
Record an application event in the durable source feed.
§Errors
Returns an error if the service is not configured as a source or the durable replication event cannot be appended.
Sourcepub fn record_change(&mut self, change: &Value) -> ThingdResult<()>
pub fn record_change(&mut self, change: &Value) -> ThingdResult<()>
Record a provider-neutral change payload in the source feed.
This is the escape hatch for transports that already construct the
public operation envelope. Prefer the typed record_* methods for
native callers.
§Errors
Returns an error if the service is not configured as a source or the durable replication event cannot be appended.
Sourcepub fn events(
&mut self,
after: u64,
limit: u64,
) -> ThingdResult<ReplicationPage>
pub fn events( &mut self, after: u64, limit: u64, ) -> ThingdResult<ReplicationPage>
Read a source page after a cursor.
§Errors
Returns an error when the cursor has fallen outside the retained replication event window or the event store cannot be read.
Sourcepub fn snapshot(&mut self) -> ThingdResult<ReplicationSnapshot>
pub fn snapshot(&mut self) -> ThingdResult<ReplicationSnapshot>
Create a source snapshot containing only replicable data.
§Errors
Returns an error when the object or event stores cannot be read.
Sourcepub fn apply(
&mut self,
changes: &[ReplicationChange],
) -> ThingdResult<ReplicationApplyResult>
pub fn apply( &mut self, changes: &[ReplicationChange], ) -> ThingdResult<ReplicationApplyResult>
Apply a source batch to a replica store.
§Errors
Returns an error for source-role stores, malformed changes, conflicts, or durable storage failures.
Sourcepub fn apply_snapshot(
&mut self,
snapshot: &ReplicationSnapshot,
replace: bool,
) -> ThingdResult<ReplicationApplyResult>
pub fn apply_snapshot( &mut self, snapshot: &ReplicationSnapshot, replace: bool, ) -> ThingdResult<ReplicationApplyResult>
Apply a bootstrap snapshot to a replica.
§Errors
Returns an error for source-role stores, conflicts, or durable storage failures.
Sourcepub fn status(&mut self) -> ThingdResult<ReplicationStatus>
pub fn status(&mut self) -> ThingdResult<ReplicationStatus>
Return status for the configured source/replica.
§Errors
Returns an error when replication state cannot be read.
Sourcepub fn conflicts(&mut self) -> ThingdResult<Vec<MemoryObject>>
pub fn conflicts(&mut self) -> ThingdResult<Vec<MemoryObject>>
List durable quarantined conflicts.
§Errors
Returns an error when the conflict collection cannot be read.
Auto Trait Implementations§
impl<'a> !RefUnwindSafe for ReplicationService<'a>
impl<'a> !Send for ReplicationService<'a>
impl<'a> !Sync for ReplicationService<'a>
impl<'a> !UnwindSafe for ReplicationService<'a>
impl<'a> Freeze for ReplicationService<'a>
impl<'a> Unpin for ReplicationService<'a>
impl<'a> UnsafeUnpin for ReplicationService<'a>
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
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.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> ⓘ
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> ⓘ
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