feat: retry on 5xx and exceptions
Signed-off-by: Infi <infi@infi.sh>
This commit is contained in:
parent
2d8e9c3804
commit
73a2d6cf17
|
|
@ -71,8 +71,6 @@ fun buildUserAgent(accessMethod: String = "Ktor"): String {
|
||||||
return "$accessMethod RevoltAndroid/${BuildConfig.VERSION_NAME} ${BuildConfig.APPLICATION_ID} (Android ${android.os.Build.VERSION.SDK_INT}; ${android.os.Build.MANUFACTURER} ${android.os.Build.DEVICE}; (Kotlin ${KotlinVersion.CURRENT})"
|
return "$accessMethod RevoltAndroid/${BuildConfig.VERSION_NAME} ${BuildConfig.APPLICATION_ID} (Android ${android.os.Build.VERSION.SDK_INT}; ${android.os.Build.MANUFACTURER} ${android.os.Build.DEVICE}; (Kotlin ${KotlinVersion.CURRENT})"
|
||||||
}
|
}
|
||||||
|
|
||||||
private const val BACKEND_IS_STABLE = false
|
|
||||||
|
|
||||||
@OptIn(ExperimentalSerializationApi::class)
|
@OptIn(ExperimentalSerializationApi::class)
|
||||||
val RevoltJson = Json {
|
val RevoltJson = Json {
|
||||||
ignoreUnknownKeys = true
|
ignoreUnknownKeys = true
|
||||||
|
|
@ -92,17 +90,15 @@ val RevoltHttp = HttpClient(OkHttp) {
|
||||||
|
|
||||||
install(WebSockets)
|
install(WebSockets)
|
||||||
|
|
||||||
if (BACKEND_IS_STABLE) {
|
install(HttpRequestRetry) {
|
||||||
install(HttpRequestRetry) {
|
retryOnServerErrors(maxRetries = 5)
|
||||||
retryOnServerErrors(maxRetries = 5)
|
retryOnException(maxRetries = 5)
|
||||||
retryOnException(maxRetries = 5)
|
|
||||||
|
|
||||||
modifyRequest { request ->
|
modifyRequest { request ->
|
||||||
request.headers.append("x-retry-count", retryCount.toString())
|
request.headers.append("x-retry-count", retryCount.toString())
|
||||||
}
|
|
||||||
|
|
||||||
exponentialDelay()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
exponentialDelay()
|
||||||
}
|
}
|
||||||
|
|
||||||
install(Logging) { level = LogLevel.INFO }
|
install(Logging) { level = LogLevel.INFO }
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue