-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Labels
priority: lowNice to have, can waitNice to have, can waittype: refactorCode improvement without changing functionalityCode improvement without changing functionality
Description
Summary
RobustSubscription currently tracks provider state (current_fallback_index, last_reconnect_attempt) and implements reconnection logic (try_reconnect_to_primary, switch_to_fallback). This violates separation of concerns—provider management should be the responsibility of RobustProvider, not the subscription.
Current Problems
1. RobustSubscription knows too much about providers
- Tracks
current_fallback_indexandlast_reconnect_attempt - Directly calls
try_fallback_providers_fromandtry_provider_with_timeout - Implements
try_reconnect_to_primarylogic
2. Reconnection logic is subscription-agnostic
- The periodic reconnection to primary provider is general
RobustProviderfunctionality - Has nothing to do with subscriptions specifically
- Should be reusable for other operations
3. Tight coupling
RobustSubscriptionneeds internal knowledge ofRobustProvider's fallback mechanism- Makes both components harder to maintain and test independently
Proposed Solution
RobustSubscription should only:
- Hold the current subscription
- Call
recv()and handle timeouts - Tell
RobustProvider: "give me a new subscription" when errors occur
RobustProvider should:
- Track which provider is currently active (primary vs fallback index)
- Track
last_reconnect_attempt - Implement
try_reconnect_to_primarylogic - Expose a method like
subscribe_blocks_with_failover()that handles all provider switching internally
Metadata
Metadata
Assignees
Labels
priority: lowNice to have, can waitNice to have, can waittype: refactorCode improvement without changing functionalityCode improvement without changing functionality