Struct SyncManager

Source
pub struct SyncManager { /* private fields */ }
Expand description

Manages synchronization of a Dolt repository across peers.

§Fields

  • mailbox – The Mailbox instance used to send and receive messages.
  • repo_path – Filesystem path to the local Dolt repository.

§Rationale

The CHORUS architecture relies on deterministic state replication. By broadcasting the latest commit hash (sync_signal) each peer can decide whether to pull updates. This struct encapsulates that behaviour, keeping the rest of the system agnostic of the underlying VCS commands.

Implementations§

Source§

impl SyncManager

Source

pub fn new(mailbox: Mailbox, repo_path: PathBuf) -> Self

Creates a new SyncManager.

§Parameters
  • mailbox – An already‑opened Mailbox for peer communication.
  • repo_path – Path to the Dolt repository that should be kept in sync.

Returns a fully‑initialised manager ready to broadcast or handle sync signals.

Source

pub fn broadcast_state( &self, from_peer: &str, to_peer: &str, ) -> Result<(), Box<dyn Error>>

Broadcasts the current repository state to a remote peer.

The method executes dolt log -n 1 --format %H to obtain the most recent commit hash, constructs a Message with topic "sync_signal" and sends it via the mailbox.

  • from_peer – Identifier of the sender.
  • to_peer – Identifier of the intended recipient.
§Errors

Returns any I/O or command‑execution error wrapped in a boxed dyn Error.

Source

pub fn handle_sync_signal(&self, msg: &Message) -> Result<(), Box<dyn Error>>

Handles an incoming sync_signal message.

If the message topic is not "sync_signal" the function returns Ok(()) immediately. Otherwise it extracts the remote commit hash and attempts a dolt pull origin to bring the local repository up‑to‑date. In a real P2P deployment the remote URL would be derived from the sender, but the current implementation uses the default remote configuration.

§Errors

Propagates any command execution failures.

Auto Trait Implementations§

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