Skip to main content

ask_to_sync

Function ask_to_sync 

Source
pub fn ask_to_sync(
    records: &Records,
    replica: Option<EntityId>,
    now: &dyn Fn() -> u64,
    wait: Duration,
) -> Result<Option<u64>, NodeError>
Expand description

Asks the program that holds the sync role of the replica, whichever it is, to sync with one other replica, or with all it finds, and waits until it did, for at most wait: waits first for a program to take the role, if none holds it, and for one that just took it to look for the others on the network, which it connects to at once in its first while (Holding::APPEAR_WAIT). Returns when it asked, after which the holder recorded each sync of the answer (crate::ReplicaRecord::synced); or None if no program answered in time. now is the wall clock, as the holder’s is.

§Errors

Returns an error if the records cannot be read or written.