complete source discovery processing lifecycle
This commit is contained in:
@@ -85,10 +85,16 @@ def backoff_delay(attempt: int, base: float = 0.5, maximum: float = 30.0, jitter
|
||||
return exponential_backoff(attempt, base, maximum, jitter)
|
||||
|
||||
def circuit_is_open(consecutive_failures: int, threshold: int = 3) -> bool:
|
||||
return int(consecutive_failures) >= threshold
|
||||
return int(consecutive_failures) >= max(1, int(threshold))
|
||||
|
||||
def quota_remaining(used: int, limit: int | None) -> int | None:
|
||||
"""Return remaining quota, clamped so malformed values fail closed."""
|
||||
if limit is None: return None
|
||||
return max(0, int(limit) - max(0, int(used)))
|
||||
|
||||
def quota_allowed(used: int, limit: int | None) -> bool:
|
||||
return limit is None or (limit >= 0 and used < limit)
|
||||
remaining = quota_remaining(used, limit)
|
||||
return remaining is None or remaining > 0
|
||||
|
||||
def rate_limit_delay(last_request: float | None, min_interval: float) -> float:
|
||||
if last_request is None: return 0.0
|
||||
|
||||
Reference in New Issue
Block a user