Jeremie
10/25/2021, 4:44 PMmbonnin
10/25/2021, 4:46 PMFlow.retry{}
with Flow or a simple while loop for suspend functionsJeremie
10/25/2021, 5:20 PMmbonnin
10/25/2021, 5:27 PMprivate suspend fun <D: Query.Data> ApolloClient.executeWithRetries(
query: Query<D>,
maxRetries: Int,
delayMillis: Long
): ApolloResponse<D> {
var retries = 0
while (retries < maxRetries) {
try {
return query(query)
} catch (e: Exception) {
delay(delayMillis)
retries++
}
}
throw Exception("max retries reached")
}
Jeremie
10/25/2021, 5:28 PMmbonnin
10/25/2021, 5:29 PMundermark5
10/27/2021, 2:42 PMabstract class RetryStrategy
providing some common implementations (linear, exponential, etc)? This would provide some common strategies, but while allowing us to define our own.mbonnin
10/27/2021, 3:20 PMFlow
case, I'm pretty sure there are implementations out there. For the suspend
case, it's a bit of boilerplate but maybe there are extensions to do this somewhere.