Back off by itself when the server is slow; read the library overnight (5,000 titles a night)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -58,4 +58,23 @@ class SafetyLimitsTest {
|
||||
while (background()) made++
|
||||
assertEquals(100, made)
|
||||
}
|
||||
|
||||
@Test fun backgroundEasesOffWhenTheServerIsSlowAndRecovers() {
|
||||
BackgroundPacing.run {
|
||||
repeat(3) { BackgroundPacing.observe(3_000, true) } // three slow answers
|
||||
assertEquals(12_000L, BackgroundPacing.gapMs); assertTrue(BackgroundPacing.easedOff)
|
||||
repeat(10) { BackgroundPacing.observe(100, false) } // errors: up to the ceiling, no further
|
||||
assertEquals(BackgroundPacing.MAX_GAP_MS, BackgroundPacing.gapMs)
|
||||
repeat(40) { BackgroundPacing.observe(100, true) } // quick again: back to normal, not below
|
||||
assertEquals(BackgroundPacing.GAP_MS, BackgroundPacing.gapMs); assertFalse(BackgroundPacing.easedOff)
|
||||
}
|
||||
// Watching never moves it.
|
||||
BackgroundPacing.observe(30_000, false)
|
||||
assertEquals(BackgroundPacing.GAP_MS, BackgroundPacing.gapMs)
|
||||
}
|
||||
|
||||
@Test fun theOvernightReadOnlyRunsInTheSmallHours() {
|
||||
assertEquals(1..5, OVERNIGHT_HOURS)
|
||||
assertEquals(5_000, OVERNIGHT_HOURS.count() * OVERNIGHT_PAGES_PER_HOUR * CATALOGUE_PAGE_SIZE)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user