Skip to content

Rate-window arithmetic

rn_forge.auth.rate_window

Arithmetic for fixed-window rate-limit keys and retry times.

fixed_window_key(scope, subject, window_seconds, now)

Return the scope-subject digest and bucket for now in epoch seconds.

fixed_window_retry_after(window_seconds, now)

Return whole seconds until the current window ends, for epoch now.

fixed_window_seconds(window)

Return window in whole seconds, rounded up and at least one.