Skip to main content

MultiPeerCatchUp

Struct MultiPeerCatchUp 

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

Pipelined catch-up from multiple peer nodes simultaneously.

Spawns one thread per peer in peers and waits for all to finish (or for the first to succeed). Returns the name of the peer that supplied the entries, or None if no peer could serve the range.

The log_writer_factory closure is called once per thread to produce a per-thread LogWriter. The factory must be Send + Sync.

Implementations§

Source§

impl MultiPeerCatchUp

Source

pub fn new(peers: Vec<(String, SocketAddr)>, start_vlsn: u64) -> Self

Create a new multi-peer catch-up request.

peers is a list of (node_name, socket_addr) pairs to try.

Source

pub fn run<F, W>(self, make_writer: F) -> Option<String>
where F: Fn() -> W + Send + Sync + 'static, W: LogWriter + Send + 'static,

Run pipelined catch-up.

Spawns one thread per peer and waits for the first to succeed. Each thread calls catch_up_from_peer; the winning thread’s entries are applied through make_writer(). Other threads are joined once the first succeeds.

Returns the name of the first peer that successfully served the range, or None if all peers declined.

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V