refactor: RetryPolicyをcommonパッケージのものに統一

This commit is contained in:
2024-03-05 12:14:49 +09:00
parent 8c7133f233
commit 8f5c1715c3
4 changed files with 18 additions and 32 deletions
@@ -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
}