Base毫秒(millisecond的缩写)重试政策(Policy)

Java-friendly base for implementing a RetryPolicy. Java cannot return the Duration that nextRetryDelay needs, so a Java subclass implements shouldRetry and nextRetryDelayMillis instead. Like any RetryPolicy, it must be thread-safe and return quickly.

构造函数(Constructors)

Link copied to clipboard
constructor()

函数

Link copied to clipboard
override fun nextRetryDelay(failedAttempts: Int): Duration

该函数返回在下一次尝试之前需要等待的延迟时间(单位:秒)。 failedAttempts 尝试已经失败,该函数只有在其他所有尝试都失败后才会被调用。 shouldRetry 返回了 true如果延迟时间为零或负数,则会立即重新尝试(即立即再次执行该操作)。 Duration.INFINITE 会一直等待,直到尝试重试的协程被取消为止。

Link copied to clipboard
abstract fun shouldRetry(failure: Exception, failedAttempts: Int): Boolean

返回一个布尔值,表示是否需要重试一次。 failedAttempts 至少有 1 次尝试失败了,最后一次尝试的具体情况是……(此处应填写最后一次尝试的详细信息)。 失败;故障.