pub struct ConnectionConfig {
pub endpoint: Endpoint,
pub reconnect: ReconnectConfig,
pub connect_timeout: Duration,
pub depth: Depth,
pub heartbeat_timeout: Option<Duration>,
pub channel_capacity: Option<usize>,
pub backpressure_policy: BackpressurePolicy,
pub circuit_breaker: Option<CircuitBreakerConfig>,
}Expand description
Configuration for the WebSocket connection
Fields§
§endpoint: EndpointWebSocket endpoint
reconnect: ReconnectConfigReconnection settings
connect_timeout: DurationConnection timeout
depth: DepthOrderbook depth to subscribe with
heartbeat_timeout: Option<Duration>Heartbeat timeout - disconnect if no heartbeat received within this duration Kraken sends heartbeats every ~5 seconds; default timeout is 30 seconds
channel_capacity: Option<usize>Event channel capacity (None = unbounded)
backpressure_policy: BackpressurePolicyBackpressure policy when channel is full
circuit_breaker: Option<CircuitBreakerConfig>Circuit breaker configuration (None = disabled)
Implementations§
Source§impl ConnectionConfig
impl ConnectionConfig
Sourcepub fn with_endpoint(self, endpoint: Endpoint) -> Self
pub fn with_endpoint(self, endpoint: Endpoint) -> Self
Set the endpoint
Sourcepub fn with_reconnect(self, config: ReconnectConfig) -> Self
pub fn with_reconnect(self, config: ReconnectConfig) -> Self
Set reconnection config
Sourcepub fn without_reconnect(self) -> Self
pub fn without_reconnect(self) -> Self
Disable automatic reconnection
Sourcepub fn with_timeout(self, timeout: Duration) -> Self
pub fn with_timeout(self, timeout: Duration) -> Self
Set connection timeout
Sourcepub fn with_depth(self, depth: Depth) -> Self
pub fn with_depth(self, depth: Depth) -> Self
Set orderbook depth
Sourcepub fn with_heartbeat_timeout(self, timeout: Duration) -> Self
pub fn with_heartbeat_timeout(self, timeout: Duration) -> Self
Set heartbeat timeout
If no message is received within this duration, the connection is considered dead and will be reconnected.
Sourcepub fn without_heartbeat_timeout(self) -> Self
pub fn without_heartbeat_timeout(self) -> Self
Disable heartbeat timeout monitoring
Sourcepub fn with_channel_capacity(
self,
capacity: usize,
policy: BackpressurePolicy,
) -> Self
pub fn with_channel_capacity( self, capacity: usize, policy: BackpressurePolicy, ) -> Self
Set bounded channel capacity for backpressure handling
When the channel is full and a new event arrives:
DropNewest: The new event is dropped (default)Block: The sender blocks until space is available (may cause connection issues)
Recommended capacity: 1000-10000 depending on message rate
Sourcepub fn with_unbounded_channel(self) -> Self
pub fn with_unbounded_channel(self) -> Self
Use unbounded channel (no backpressure, unlimited memory growth)
Sourcepub fn with_circuit_breaker(self, config: CircuitBreakerConfig) -> Self
pub fn with_circuit_breaker(self, config: CircuitBreakerConfig) -> Self
Enable circuit breaker with custom configuration
The circuit breaker prevents repeated connection attempts when the service appears unhealthy, giving it time to recover.
Sourcepub fn without_circuit_breaker(self) -> Self
pub fn without_circuit_breaker(self) -> Self
Disable circuit breaker
Trait Implementations§
Source§impl Clone for ConnectionConfig
impl Clone for ConnectionConfig
Source§fn clone(&self) -> ConnectionConfig
fn clone(&self) -> ConnectionConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more