Module websocket_unified

Source
Expand description

Unified WebSocket Trading Components

This module provides common abstractions, traits, and utilities for WebSocket trading implementations across all supported exchanges. It eliminates code duplication and ensures consistent behavior patterns.

§Features

  • Unified Connection State Management: Standardized state machine for all exchanges
  • Common Authentication Interface: Pluggable authentication mechanisms
  • Standardized Health Monitoring: Consistent ping/pong and health tracking
  • Shared Reconnection Logic: Exponential backoff with configurable parameters
  • Unified Rate Limiting: Configurable rate limiting for all exchanges
  • Common Request Management: Standardized request ID generation and tracking

Structs§

ConnectionHealth
Standard health information for WebSocket connections
ConnectionStateManager
Connection state manager for thread-safe state management
HealthConfig
Configuration for WebSocket health monitoring
RateLimitConfig
Configuration for rate limiting
ReconnectionConfig
Configuration for reconnection behavior
ReconnectionManager
Reconnection manager with exponential backoff
UnifiedRateLimiter
Unified rate limiter for WebSocket requests
WebSocketTaskHandles
Standard task handles for WebSocket connections

Enums§

RequestId
Request ID management for tracking WebSocket requests
WebSocketConnectionState
Unified connection state for all WebSocket trading implementations

Traits§

AuthenticationMechanism
Authentication mechanism trait for different exchange authentication methods
WebSocketTrader
Common WebSocket trading interface

Functions§

calculate_backoff_with_jitter
Helper function to create exponential backoff with jitter
validate_websocket_response
Utility function to validate WebSocket response structure

Type Aliases§

PendingRequestsMap
Request management for tracking pending WebSocket requests