Skip to content

fix: add lightweight recovery framework with retry‑backoff#323

Open
saidai-bhuvanesh wants to merge 1 commit into
ProdigyV21:mainfrom
saidai-bhuvanesh:resilience-recovery
Open

fix: add lightweight recovery framework with retry‑backoff#323
saidai-bhuvanesh wants to merge 1 commit into
ProdigyV21:mainfrom
saidai-bhuvanesh:resilience-recovery

Conversation

@saidai-bhuvanesh
Copy link
Copy Markdown
Contributor

Description:

This PR introduces a small, evidence‑driven recovery layer to improve the app’s resilience against transient network failures and crashes.

Key Additions

  • RecoveryCoordinator.kt
    • Provides runWithRecovery for any suspend operation.
    • Implements exponential back‑off (default 3 attempts, starting at 500 ms) and returns the project’s Result<T> type.
  • WorkerRecoveryHelper.kt
    • Offers safeExecute for CoroutineWorker implementations.
    • Retries only on network‑related AppExceptions, preserving existing worker semantics.

Repository Updates

  • IptvRepository.kt
    • Wrapped fetchChannelsForPlaylistWithRetries with RecoveryCoordinator to centralize retry logic and convert exceptions to Result.Error.
  • (Pending) StreamRepository.kt and TraktSyncWorker.kt will be refactored similarly to use the new helpers (already staged in this branch).

Tests

  • New unit tests (RecoveryCoordinatorTest.kt & WorkerRecoveryHelperTest.kt) verify retry counts, back‑off behavior, and correct error handling.

Benefits

  • Prevents crashes caused by uncaught throw statements in network code.
  • Provides consistent, configurable retry handling across repositories and workers.
  • Keeps the implementation lightweight and modular, aligning with the evidence‑driven approach.

Please review the changes, approve, and merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant