Mikhail Kilin
|
c6beea5608
|
refactor: create timeout/retry utilities to reduce code duplication (P1.1)
Created new utility modules to eliminate repeated timeout/retry patterns:
- src/utils/retry.rs: with_timeout() and with_timeout_msg() helpers
- src/utils/formatting.rs: timestamp formatting utilities (from utils.rs)
- src/utils/tdlib.rs: TDLib log configuration utilities (from utils.rs)
Refactored src/input/main_input.rs:
- Replaced 18+ instances of timeout(Duration, op).await pattern
- Simplified error handling from nested Ok(Ok(...))/Ok(Err(...))/Err(...)
to cleaner Ok(...)/Err(...) with custom timeout messages
- Added type annotations for compiler type inference
Benefits:
- Reduced code duplication from ~20 instances to 2 utility functions
- Cleaner, more readable error handling
- Easier to maintain timeout logic in one place
- All 59 tests passing
Progress: REFACTORING_OPPORTUNITIES.md #1 (Дублирование кода) - Частично выполнено
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
|
2026-02-01 19:56:33 +03:00 |
|