fix: bound provider storage retries
This commit is contained in:
+4
-8
@@ -28,12 +28,9 @@ class ProviderProfileStoreImpl(
|
||||
private val safeData: Flow<Preferences>
|
||||
get() = dataStore.data
|
||||
.retryWhen { cause, attempt ->
|
||||
if (cause !is IOException) return@retryWhen false
|
||||
val delayMillis = (READ_RETRY_DELAY_MILLIS shl
|
||||
attempt.coerceAtMost(MAX_BACKOFF_SHIFT).toInt())
|
||||
.coerceAtMost(MAX_READ_RETRY_DELAY_MILLIS)
|
||||
delay(delayMillis)
|
||||
true
|
||||
val retry = cause is IOException && attempt < MAX_READ_RETRIES
|
||||
if (retry) delay(READ_RETRY_DELAY_MILLIS)
|
||||
retry
|
||||
}
|
||||
.distinctUntilChanged()
|
||||
|
||||
@@ -118,9 +115,8 @@ class ProviderProfileStoreImpl(
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val MAX_READ_RETRIES = 2L
|
||||
private const val READ_RETRY_DELAY_MILLIS = 100L
|
||||
private const val MAX_READ_RETRY_DELAY_MILLIS = 5_000L
|
||||
private const val MAX_BACKOFF_SHIFT = 6L
|
||||
private val PROFILE_IDS = stringSetPreferencesKey("profile_ids")
|
||||
private val ACTIVE_PROFILE_ID = stringPreferencesKey("active_profile_id")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user