feat: キューがタイムアウトしたらそれを保存するように

This commit is contained in:
2024-03-06 21:17:29 +09:00
parent 1e57f1ef4b
commit dcc1f582a9
14 changed files with 88 additions and 39 deletions
@@ -6,6 +6,6 @@ import kotlin.math.roundToLong
class ExponentialRetryPolicy(private val firstRetrySeconds: Int = 30) : RetryPolicy {
override fun nextRetry(now: Instant, attempt: Int): Instant =
now.plusSeconds(firstRetrySeconds.times((2.0).pow(attempt).roundToLong()))
now.plusSeconds(firstRetrySeconds.times((2.0).pow(attempt).roundToLong()) - 30)
}
@@ -25,12 +25,12 @@ class ExponentialRetryPolicyTest {
fun exponential0() {
val nextRetry = ExponentialRetryPolicy().nextRetry(Instant.ofEpochSecond(300), 0)
assertEquals(Instant.ofEpochSecond(330), nextRetry)
assertEquals(Instant.ofEpochSecond(300), nextRetry)
}
@Test
fun exponential1() {
val nextRetry = ExponentialRetryPolicy().nextRetry(Instant.ofEpochSecond(300), 1)
assertEquals(Instant.ofEpochSecond(360), nextRetry)
assertEquals(Instant.ofEpochSecond(330), nextRetry)
}
}