Interface RateLimitDecision

All Known Implementing Classes:
RateLimitDecision.Allowed, RateLimitDecision.Throttled

@ExperimentalJSentinelApi public sealed interface RateLimitDecision permits RateLimitDecision.Allowed, RateLimitDecision.Throttled
Result of a RateLimitPolicy.tryAcquire(RateLimitKey) call.

Sealed because adapters dispatch on the two outcomes — let the request through or refuse it with a 429 Too Many Requests (REST) / equivalent rejection (UI).

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static final record 
    The event was admitted; the caller proceeds.
    static final record 
    The event was refused — the per-window count is already at or above the configured limit.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
     
    int
     
     
  • Method Details

    • eventsInWindow

      int eventsInWindow()
      Returns:
      the per-window event count after this decision (used / observed)
    • limit

      int limit()
      Returns:
      the configured per-window limit
    • window

      Duration window()
      Returns:
      the configured window duration