Repository navigation
Peek, SetLimit, return observed
Allow and AllowN now return (admit bool, observed int) instead of just bool, where observed is the sliding window's load measured before the call — useful for anchoring downstream rejection responses (e.g. a 429) to the actually emitted rate. Two new non-mutating methods, Peek and PeekN, answer the same admit-or-not question without consuming a slot, suitable for filtering candidates or preempting work based on current load. The throttle's limit is now runtime-adjustable via SetLimit and readable via Limit; counters are preserved across changes so the new limit applies against the existing sliding-window history rather than resetting it. Existing call sites must be updated to destructure the new return value (admit, _ := th.Allow()).