pub struct LogSync<S, L, E, TM>where
S: OperationStore<L, E> + LogStore<L, E> + Send + 'static,
L: LogId + Serialize + for<'de> Deserialize<'de> + Send + 'static,
E: Extensions + Send + 'static,
TM: TopicMap<TopicId, Logs<L>> + Send + 'static,{ /* private fields */ }Expand description
Eventually consistent, local-first sync protocol based on append-only logs.
§Example
See chat.rs for a full example using the sync protocol.
§Local-first
In local-first applications we want to converge towards the same state eventually, which requires nodes to catch up on missed messages - independent of if they’ve been offline or not.
p2panda-net comes with a default LogSync protocol implementation which uses p2panda’s
append-only log Base Convergent Data Type (CDT).
After initial sync has finished, nodes switch to live-mode to directly push new messages to the network using a gossip protocol.
Implementations§
Source§impl<S, L, E, TM> LogSync<S, L, E, TM>where
S: OperationStore<L, E> + LogStore<L, E> + Send + 'static,
L: LogId + Serialize + for<'de> Deserialize<'de> + Send + 'static,
E: Extensions + Send + 'static,
TM: TopicMap<TopicId, Logs<L>> + Send + 'static,
impl<S, L, E, TM> LogSync<S, L, E, TM>where
S: OperationStore<L, E> + LogStore<L, E> + Send + 'static,
L: LogId + Serialize + for<'de> Deserialize<'de> + Send + 'static,
E: Extensions + Send + 'static,
TM: TopicMap<TopicId, Logs<L>> + Send + 'static,
pub fn builder( store: S, topic_map: TM, endpoint: Endpoint, gossip: Gossip, ) -> Builder<S, L, E, TM>
pub async fn stream( &self, topic: TopicId, live_mode: bool, ) -> Result<SyncHandle<Operation<E>, TopicLogSyncEvent<E>>, LogSyncError<E>>
Trait Implementations§
Auto Trait Implementations§
impl<S, L, E, TM> Freeze for LogSync<S, L, E, TM>
impl<S, L, E, TM> !RefUnwindSafe for LogSync<S, L, E, TM>
impl<S, L, E, TM> Send for LogSync<S, L, E, TM>
impl<S, L, E, TM> Sync for LogSync<S, L, E, TM>
impl<S, L, E, TM> Unpin for LogSync<S, L, E, TM>
impl<S, L, E, TM> !UnwindSafe for LogSync<S, L, E, TM>
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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> Message for T
impl<T> Message for T
Source§fn from_boxed(m: BoxedMessage) -> Result<Self, BoxedDowncastErr>
fn from_boxed(m: BoxedMessage) -> Result<Self, BoxedDowncastErr>
Convert a BoxedMessage to this concrete type
Source§fn box_message(self, pid: &ActorId) -> Result<BoxedMessage, BoxedDowncastErr>
fn box_message(self, pid: &ActorId) -> Result<BoxedMessage, BoxedDowncastErr>
Convert this message to a BoxedMessage