Skip to main content

ReplicationService

Struct ReplicationService 

Source
pub struct ReplicationService<'a> { /* private fields */ }
Expand description

Backend-neutral replication operations over a Thingd store.

Implementations§

Source§

impl<'a> ReplicationService<'a>

Source

pub fn new(engine: &'a mut dyn ThingStore, config: ReplicationConfig) -> Self

Create a service over an existing in-memory or persistent engine.

Source

pub const fn config(&self) -> &ReplicationConfig

Return the service configuration.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn status(&mut self) -> ThingdResult<ReplicationStatus>

Return status for the configured source/replica.

§Errors

Returns an error when replication state cannot be read.

Source

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Converts 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>

Converts 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)

Converts &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)

Converts &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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.