Skip to content

Commit 09e06ae

Browse files
robster7674claude
andauthored
refactor(telegram): derive STALE_THROTTLE_MS from TRANSIENT_RETRY_DELAY_MS
Addresses greptile style nit from PR #40: STALE_THROTTLE_MS is expressed as TRANSIENT_RETRY_DELAY_MS + 10_000L, making the throttle > retry-delay invariant structurally self-enforcing. Drops the now-redundant usage-site comment that restated the relationship. No behavioral change; value remains 70 000 ms. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 829849b commit 09e06ae

1 file changed

Lines changed: 4 additions & 7 deletions

File tree

Common/src/main/java/tk/glucodata/TelegramStaleCheckWork.kt

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ object TelegramStaleCheckWork {
3636

3737
private const val STALE_PREFIX = "telegram_stale_check:"
3838
private const val TRANSIENT_RETRY_DELAY_MS = 60_000L
39-
// Must exceed TRANSIENT_RETRY_DELAY_MS: a recipient that just posted STALE is
40-
// throttled on the 60 s retry cycle but re-evaluated when the missed-threshold
41-
// timer fires (which can be minutes later).
42-
private const val STALE_THROTTLE_MS = 70_000L
39+
// Derived from TRANSIENT_RETRY_DELAY_MS to keep the invariant self-enforcing:
40+
// a recipient that just posted STALE is skipped on the 60 s retry cycle but
41+
// re-evaluated when the missed-threshold timer fires later.
42+
private const val STALE_THROTTLE_MS = TRANSIENT_RETRY_DELAY_MS + 10_000L
4343

4444
fun schedule(context: Context, destinationId: String, delayMs: Long) {
4545
val key = STALE_PREFIX + destinationId
@@ -83,9 +83,6 @@ object TelegramStaleCheckWork {
8383
else -> continue
8484
}
8585
val lastStaleMs = destination.lastStaleAtMsByRecipient[recipient] ?: 0L
86-
// STALE_THROTTLE_MS > TRANSIENT_RETRY_DELAY_MS: a recipient that just
87-
// succeeded is skipped on the 60 s retry cycle but re-evaluated when
88-
// the missed-threshold timer fires later.
8986
if (lastStaleMs > 0L && now - lastStaleMs < STALE_THROTTLE_MS) continue
9087
val hasActiveBubble = (destination.lastMessageIdByRecipient[recipient] ?: 0L) > 0L
9188
if (!hasActiveBubble) continue

0 commit comments

Comments
 (0)