-
Notifications
You must be signed in to change notification settings - Fork 18
Open
Labels
Description
Add retry logic with exponential backoff to all Stellar Horizon API calls inside StellarClient. Network failures and transient Horizon errors should be retried automatically rather than immediately failing.
Requirements:
- Create a
RetryConfigstruct:pub struct RetryConfig { pub max_attempts: u32, pub initial_delay_ms: u64, pub max_delay_ms: u64, pub backoff_multiplier: f64, }
- Implement a generic
retry_async<F, T>(config: &RetryConfig, operation: F) -> Result<T>utility function whereFis an async closure - Apply jitter to the delay:
actual_delay = delay * (0.8 + random * 0.4)usingrand::random::<f64>() - Retry only on:
- Network errors (connection refused, timeout)
- Horizon
5xxHTTP responses - Do NOT retry on
4xxresponses
- Log each retry attempt at
warn!level with attempt number and delay - Apply this to
verify_hash,submit_hash, andget_hash_history - Make
max_attemptsconfigurable viaSTELLAR_MAX_RETRIESenv var (default: 3)
Acceptance Criteria:
retry_asynccorrectly stops aftermax_attempts- Backoff delay increases between retries with jitter
4xxresponses are NOT retried- Unit tests for the retry logic using mock operations that fail N times then succeed
Reactions are currently unavailable