Package io.jans.fido2.service.readiness
Class ReadinessRateLimiter
java.lang.Object
io.jans.fido2.service.readiness.ReadinessRateLimiter
Bounds how much outbound work the readiness endpoint can cause, per node. Three limits, all constants:
- a relying party is fetched at most once per
MIN_RECHECK_INTERVAL_MS; - at most
MAX_FETCHES_PER_WINDOWfiles are fetched perWINDOW_MS, whichever relying parties they belong to; - at most
MAX_CONCURRENTchecks run at the same time.
Retry-After.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intstatic final longstatic final long -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionlongnextAllowedAt(String rpId) Earliest time, in epoch milliseconds, at whichrpIdmay be fetched again.voidrelease()longtryAcquire(String rpId, int fetches) Asks to run a check that fetchesfetchesfiles forrpId.
-
Field Details
-
MIN_RECHECK_INTERVAL_MS
public static final long MIN_RECHECK_INTERVAL_MS- See Also:
-
WINDOW_MS
public static final long WINDOW_MS- See Also:
-
MAX_FETCHES_PER_WINDOW
public static final int MAX_FETCHES_PER_WINDOW- See Also:
-
MAX_CONCURRENT
public static final int MAX_CONCURRENT- See Also:
-
-
Constructor Details
-
ReadinessRateLimiter
public ReadinessRateLimiter()
-
-
Method Details
-
tryAcquire
Asks to run a check that fetchesfetchesfiles forrpId.- Returns:
- 0 when granted (the caller must then call
release()), otherwise the number of milliseconds to wait before asking again
-
release
public void release() -
nextAllowedAt
Earliest time, in epoch milliseconds, at whichrpIdmay be fetched again.
-