feat(limit-count): upgrade lua-resty-limit-traffic to v1.2.0#13212
Merged
nic-6443 merged 3 commits intoApr 14, 2026
Conversation
Upgrade apisix-runtime from 1.3.3 to 1.3.4 which includes lua-resty-limit-traffic v1.2.0. The library changed from counting down (returning remaining) to counting up (returning consumed). Changes: - limit-count-local.lua: convert consumed to remaining via self.limit - consumed, pass through error strings unchanged - limit-count/init.lua: use cost=0 with commit=false for dry_run peek (side-effect free), add manual rejection check - ai-rate-limiting-expression.t: fix remaining header values now that dry_run peek no longer deducts cost from remaining - limit-count5.t: add test for cost=0 peek behavior Reference: api7-ee-3-gateway#1090 (54a7acb)
There was a problem hiding this comment.
Pull request overview
Upgrades the bundled APISIX runtime (and its lua-resty-limit-traffic dependency) and adapts the limit-count plugin to preserve the existing “remaining quota” contract after the library changed its counter semantics to return “consumed”.
Changes:
- Bump
APISIX_RUNTIMEto1.3.4. - Convert
consumed -> remainingin the local limit-count wrapper. - Adjust local-policy dry-run to perform a side-effect-free “peek” (
commit=false,cost=0) and update tests/header expectations accordingly.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
.requirements |
Updates APISIX runtime version to pick up new limiter semantics. |
apisix/plugins/limit-count/limit-count-local.lua |
Converts returned “consumed” to “remaining” and continues computing reset. |
apisix/plugins/limit-count/init.lua |
Changes local dry-run behavior to peek without consuming quota and adds explicit rejection check. |
t/plugin/ai-rate-limiting-expression.t |
Updates expected remaining headers to match new dry-run peek behavior. |
t/plugin/limit-count5.t |
Adds a new test intended to verify that peeks don’t consume quota. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- ai-rate-limiting.t: update remaining header values (+1) because dry_run peek with cost=0 no longer deducts from remaining quota - limit-count5.t TEST 8: use unique key to avoid shared dict collision with TEST 1 which stores data for key '/t'
nic-6443
requested review from
AlinsRan,
Baoyuantop,
membphis,
moonming and
shreemaan-abhishek
April 13, 2026 11:00
shreemaan-abhishek
approved these changes
Apr 14, 2026
Baoyuantop
approved these changes
Apr 14, 2026
AlinsRan
approved these changes
Apr 14, 2026
wistefan
pushed a commit
to wistefan/apisix
that referenced
this pull request
Jun 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Upgrade
apisix-runtimefrom 1.3.3 to 1.3.4 which includeslua-resty-limit-trafficv1.2.0 (fromapi7/lua-resty-limit-traffic). The library changed its counter semantics from counting down (returningremaining) to counting up (returningconsumed).Changes
.requirementsAPISIX_RUNTIME=1.3.3→APISIX_RUNTIME=1.3.4limit-count-local.lua— consumed→remaining conversion:consumedcount instead ofremaining. The wrapper converts it back toremainingviaself.limit - consumed, preserving the existing API contract."rejected") pass through unchanged via atype()check.limit-count/init.lua— improved dry_run peek:dry_run=true: usescost=0withcommit=falsefor a side-effect-free peek.dict:getreads the counter without creating or incrementing the key.remaining - cost < 0after peek, converts to standard "rejected" flow.ai-rate-limiting-expression.t— fix remaining header values:cost=1from remaining, fixing off-by-1 inX-AI-RateLimit-Remainingheader (e.g., 499→500, 319→320).limit-count5.t— new TEST 8:cost=0peek does not consume quota: multiple peeks return stable remaining, interleaved with real commits that correctly decrement.