Expand description
Redis-backed fixed-window counter (policy: redis for limit-count and
the workflow limit-count action).
Increment-and-check runs as one server-side Lua script so concurrent
gateway instances count atomically. Window boundaries are wall-clock
aligned (now / window), so every instance agrees on them — unlike the
local store’s per-process Instant windows. Backend errors bump
gateway_counter_store_errors_total{store} and surface as
CounterError; the calling plugin decides fail-open vs reject.
Structs§
Constants§
- FIXED_
WINDOW_ 🔒SCRIPT INCR+ first-incrementPEXPIRE+PTTL, atomically.
Functions§
- window_
key 🔒 - The key for one fixed window of one counter.
- window_
slot 🔒 - Wall-clock window slot: the window index (key component shared by all
instances) and the milliseconds from
now_msto the window’s end (the PEXPIRE argument). Pure, so the boundary math is unit-testable.