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§
- Connection
Health - Standard health information for WebSocket connections
- Connection
State Manager - Connection state manager for thread-safe state management
- Health
Config - Configuration for WebSocket health monitoring
- Rate
Limit Config - Configuration for rate limiting
- Reconnection
Config - Configuration for reconnection behavior
- Reconnection
Manager - Reconnection manager with exponential backoff
- Unified
Rate Limiter - Unified rate limiter for WebSocket requests
- WebSocket
Task Handles - Standard task handles for WebSocket connections
Enums§
- Request
Id - Request ID management for tracking WebSocket requests
- WebSocket
Connection State - Unified connection state for all WebSocket trading implementations
Traits§
- Authentication
Mechanism - Authentication mechanism trait for different exchange authentication methods
- WebSocket
Trader - 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§
- Pending
Requests Map - Request management for tracking pending WebSocket requests