pub struct SyncErrorHandler { /* private fields */ }Expand description
Sync error handler with retry logic and circuit breaker
Provides centralized error handling for all sync operations with:
- Exponential backoff retry
- Circuit breaker per peer
- Health monitoring
- FFI-friendly statistics
Implementations§
Source§impl SyncErrorHandler
impl SyncErrorHandler
Sourcepub fn new() -> SyncErrorHandler
pub fn new() -> SyncErrorHandler
Create a new error handler with default policies
Sourcepub fn with_policies(
retry_policy: RetryPolicy,
circuit_config: CircuitBreakerConfig,
) -> SyncErrorHandler
pub fn with_policies( retry_policy: RetryPolicy, circuit_config: CircuitBreakerConfig, ) -> SyncErrorHandler
Create an error handler with custom policies
Sourcepub fn handle_error(
&self,
peer_id: &PublicKey,
error: SyncError,
) -> Result<Option<Duration>, SyncError>
pub fn handle_error( &self, peer_id: &PublicKey, error: SyncError, ) -> Result<Option<Duration>, SyncError>
Handle a sync error for a peer
Returns Ok(Some(delay)) if should retry after delay, Ok(None) if should not retry, or Err if circuit breaker is open.
Sourcepub fn record_success(&self, peer_id: &PublicKey)
pub fn record_success(&self, peer_id: &PublicKey)
Record a successful sync operation
Sourcepub fn peer_health(&self, peer_id: &PublicKey) -> Option<PeerHealthTracker>
pub fn peer_health(&self, peer_id: &PublicKey) -> Option<PeerHealthTracker>
Get health status for a peer
Sourcepub fn all_peer_health(&self) -> HashMap<PublicKey, PeerHealthTracker>
pub fn all_peer_health(&self) -> HashMap<PublicKey, PeerHealthTracker>
Get health status for all peers
Sourcepub fn reset_peer(&self, peer_id: &PublicKey)
pub fn reset_peer(&self, peer_id: &PublicKey)
Reset health tracking for a peer
Sourcepub fn is_circuit_open(&self, peer_id: &PublicKey) -> bool
pub fn is_circuit_open(&self, peer_id: &PublicKey) -> bool
Check if circuit breaker is open for a peer
Trait Implementations§
Source§impl Default for SyncErrorHandler
impl Default for SyncErrorHandler
Source§fn default() -> SyncErrorHandler
fn default() -> SyncErrorHandler
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for SyncErrorHandler
impl RefUnwindSafe for SyncErrorHandler
impl Send for SyncErrorHandler
impl Sync for SyncErrorHandler
impl Unpin for SyncErrorHandler
impl UnsafeUnpin for SyncErrorHandler
impl UnwindSafe for SyncErrorHandler
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> 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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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