Skip to main content

FormatCrdtProcessor

Struct FormatCrdtProcessor 

Source
pub struct FormatCrdtProcessor<P: FormatBatchProcessor> { /* private fields */ }
Expand description

CRDT-enabled processor for any format implementing FormatBatchProcessor

This wraps a FormatDsonProcessor and adds CRDT semantics:

  • Vector clock tracking for causality
  • Last-Writer-Wins (LWW) register semantics per field
  • Delta-state synchronization
  • Operation buffering for causal ordering

Implementations§

Source§

impl<P: FormatBatchProcessor> FormatCrdtProcessor<P>

Source

pub fn new(batch_processor: P, replica_id: impl Into<String>) -> Self

Create a new CRDT processor with a replica ID

Source

pub fn with_strategy(self, strategy: MergeStrategy) -> Self

Create with a specific merge strategy

Source

pub fn format_kind(&self) -> FormatKind

Get the format kind

Source

pub fn replica_id(&self) -> &str

Get the replica ID

Source

pub const fn vector_clock(&self) -> &VectorClock

Get the current vector clock

Source

pub const fn lamport_timestamp(&self) -> u64

Get the current Lamport timestamp

Source

pub fn process( &mut self, data: &[u8], schema: &CompiledSchema, ) -> Result<FormatBatchResult>

Process data with schema filtering and track as CRDT state

§Errors

Returns an error if processing fails

Source

pub fn process_with_operations( &mut self, data: &[u8], schema: &CompiledSchema, operations: &[DsonOperation], ) -> Result<FormatBatchResult>

Process with DSON operations and CRDT tracking

§Errors

Returns an error if processing fails

Source

pub fn process_unfiltered(&mut self, data: &[u8]) -> Result<FormatBatchResult>

Process unfiltered data with CRDT tracking

§Errors

Returns an error if processing fails

Source

pub fn get_document(&self, doc_id: &str) -> Option<&str>

Get a document by ID

Source

pub fn document_ids(&self) -> Vec<&str>

Get all document IDs

Source

pub fn document_count(&self) -> usize

Get number of tracked documents

Source

pub fn reset(&mut self)

Reset the processor

Source

pub const fn dson_processor(&self) -> &FormatDsonProcessor<P>

Get reference to underlying DSON processor

Source

pub fn dson_processor_mut(&mut self) -> &mut FormatDsonProcessor<P>

Get mutable reference to underlying DSON processor

Trait Implementations§

Source§

impl<P: FormatBatchProcessor> CrdtMerge for FormatCrdtProcessor<P>

Source§

fn merge_operation( &mut self, op: CrdtOperation, ) -> Result<Option<MergeConflict>>

Merge a remote operation into local state Read more
Source§

fn merge_field( &mut self, path: &str, value: OperationValue, timestamp: u64, strategy: &MergeStrategy, ) -> Result<Option<MergeConflict>>

Merge field with CRDT semantics Read more
Source§

fn vector_clock(&self) -> &VectorClock

Get the current vector clock
Source§

fn replica_id(&self) -> &str

Get the replica ID
Source§

fn resolve_conflict( &mut self, conflict: &MergeConflict, strategy: &MergeStrategy, ) -> Result<OperationValue>

Resolve a conflict using the specified strategy Read more
Source§

impl<P: FormatBatchProcessor> DeltaCrdt for FormatCrdtProcessor<P>

Source§

type Delta = FormatDelta

Type representing a delta (difference from previous state)
Source§

fn generate_delta(&self, since: &VectorClock) -> Self::Delta

Generate delta since given vector clock
Source§

fn apply_delta(&mut self, delta: Self::Delta) -> Result<Vec<MergeConflict>>

Apply delta from remote replica Read more
Source§

fn compact(&mut self)

Compact/garbage collect old deltas
Source§

impl<P: FormatBatchProcessor> OpBasedCrdt for FormatCrdtProcessor<P>

Source§

fn prepare(&self, op: &DsonOperation) -> Result<CrdtOperation>

Prepare an operation for broadcast (downstream precondition) Read more
Source§

fn effect(&mut self, op: CrdtOperation) -> Result<Option<MergeConflict>>

Effect an operation (apply after delivery) Read more
Source§

fn is_causally_ready(&self, op: &CrdtOperation) -> bool

Check if operation is causally ready to be applied
Source§

fn buffer_operation(&mut self, op: CrdtOperation)

Buffer operation until causally ready
Source§

fn process_buffered(&mut self) -> Result<Vec<MergeConflict>>

Process buffered operations that are now ready Read more

Auto Trait Implementations§

§

impl<P> Freeze for FormatCrdtProcessor<P>
where P: Freeze,

§

impl<P> RefUnwindSafe for FormatCrdtProcessor<P>
where P: RefUnwindSafe,

§

impl<P> Send for FormatCrdtProcessor<P>
where P: Send,

§

impl<P> Sync for FormatCrdtProcessor<P>
where P: Sync,

§

impl<P> Unpin for FormatCrdtProcessor<P>
where P: Unpin,

§

impl<P> UnwindSafe for FormatCrdtProcessor<P>
where P: UnwindSafe,

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> 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, 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.