Documentation IndexFetch the complete documentation index at: /llms.txtUse this file to discover all available pages before exploring further.
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Automatic recovery from connection failures
use kraken_sdk::ReconnectConfig; use std::time::Duration; let client = KrakenClient::builder(symbols) .with_reconnect(ReconnectConfig { initial_delay: Duration::from_millis(100), max_delay: Duration::from_secs(30), multiplier: 2.0, max_attempts: Some(10), // or None for unlimited }) .connect() .await?;
initial_delay
max_delay
multiplier
max_attempts
use kraken_sdk::CircuitBreakerConfig; let client = KrakenClient::builder(symbols) .with_circuit_breaker(CircuitBreakerConfig { failure_threshold: 5, reset_timeout: Duration::from_secs(30), half_open_timeout: Duration::from_secs(60), }) .connect() .await?;
match event { Event::Connection(ConnectionEvent::Disconnected { reason }) => { log::warn!("Lost connection: {:?}", reason); } Event::Connection(ConnectionEvent::Reconnecting { attempt, delay }) => { log::info!("Reconnecting (attempt {}, waiting {:?})", attempt, delay); } Event::Connection(ConnectionEvent::SubscriptionsRestored { count }) => { log::info!("Back online with {} subscriptions", count); // Safe to resume normal processing } Event::Connection(ConnectionEvent::CircuitBreakerOpen { trips }) => { log::error!("Circuit breaker open after {} trips", trips); } _ => {} }
SubscriptionsRestored
let client = KrakenClient::builder(symbols) .without_reconnect() .connect() .await?;