Tag: retrofit2 kotlinx.coroutines

如何在kotlin协议上指数退避重试

我正在使用扩展方法在网络请求中使用kotlin协同程序来调用类 public suspend fun <T : Any> Call<T>.await(): T { return suspendCancellableCoroutine { continuation -> enqueue(object : Callback<T> { override fun onResponse(call: Call<T>?, response: Response<T?>) { if (response.isSuccessful) { val body = response.body() if (body == null) { continuation.resumeWithException( NullPointerException("Response body is null") ) } else { continuation.resume(body) } } else { continuation.resumeWithException(HttpException(response)) } } […]