Skip to main content

ReconnectionManager

Struct ReconnectionManager 

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

Manager for auto-reconnection with exponential backoff

Tracks disconnected peers and determines when to attempt reconnection based on exponential backoff.

Implementations§

Source§

impl ReconnectionManager

Source

pub fn new(config: ReconnectionConfig) -> Self

Create a new reconnection manager with the given configuration

Source

pub fn with_defaults() -> Self

Create a manager with default configuration

Source

pub fn track_disconnection(&mut self, address: String)

Track a peer for reconnection after disconnection

Call this when a peer disconnects unexpectedly.

Source

pub fn is_tracked(&self, address: &str) -> bool

Check if a peer is being tracked for reconnection

Source

pub fn get_status(&self, address: &str) -> ReconnectionStatus

Get the reconnection status for a peer

Source

pub fn get_peers_to_reconnect(&self) -> Vec<String>

Get all peers that are ready for a reconnection attempt

Returns addresses of peers that:

  • Haven’t exceeded max attempts
  • Have waited long enough since the last attempt (first attempt is immediate)
Source

pub fn record_attempt(&mut self, address: &str)

Record a reconnection attempt for a peer

Call this when starting a reconnection attempt.

Source

pub fn on_connection_success(&mut self, address: &str)

Called when a connection succeeds

Removes the peer from reconnection tracking.

Source

pub fn stop_tracking(&mut self, address: &str)

Stop tracking a peer (e.g., peer was intentionally removed)

Source

pub fn clear(&mut self)

Clear all reconnection tracking

Source

pub fn tracked_count(&self) -> usize

Get the number of peers being tracked

Source

pub fn get_peer_stats(&self, address: &str) -> Option<PeerReconnectionStats>

Get statistics for a peer

Source

pub fn check_interval(&self) -> Duration

Get the check interval from configuration

Trait Implementations§

Source§

impl Debug for ReconnectionManager

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> Same for T

Source§

type Output = T

Should always be Self
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.