refactor: RetryPolicyをcommonパッケージのものに統一
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
package dev.usbharu.owl.common.retry
|
||||
|
||||
import java.time.Instant
|
||||
import kotlin.math.pow
|
||||
import kotlin.math.roundToLong
|
||||
|
||||
class ExponentialRetryPolicy(private val firstRetrySeconds: Int = 30) : RetryPolicy {
|
||||
override fun nextRetry(now: Instant, attempt: Int): Instant =
|
||||
now.plusSeconds(firstRetrySeconds.toDouble().pow(attempt + 1.0).roundToLong())
|
||||
|
||||
}
|
||||
@@ -16,5 +16,8 @@
|
||||
|
||||
package dev.usbharu.owl.common.retry
|
||||
|
||||
import java.time.Instant
|
||||
|
||||
interface RetryPolicy {
|
||||
fun nextRetry(now: Instant, attempt: Int): Instant
|
||||
}
|
||||
Reference in New Issue
Block a user