feat(limit-count): add Redis Sentinel backend, sliding window and delayed sync support#13443
Open
AlinsRan wants to merge 11 commits into
Open
feat(limit-count): add Redis Sentinel backend, sliding window and delayed sync support#13443AlinsRan wants to merge 11 commits into
AlinsRan wants to merge 11 commits into
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Add sliding-window and sliding-window/store directories to Makefile install targets so luarocks make installs all limit-count submodules - Convert oneOf 'matches both schemas' error in check_schema to the clearer message when both count/time_window and rules are present Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This dict is required by the delayed syncer module and was added to ngx_tpl.lua but missing from the default config, causing nginx to fail to start with an invalid configuration.
- Remove debug core.log.info from incoming_delayed in all 3 redis backends - Add BEGIN block to set REDIS_NODE_0/1 env vars for redis-cluster tests - Fix sentinel route URI from /hello2 to /echo (no handler for /hello2 exists) - Fix TEST 4 requests from GET /hello2 to GET /echo - Fix preprocessor to check grep_error_log before adding no_error_log Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
… test conflicts Use route ID 'limit-count-rules-1' instead of '1' to prevent state collision with other test files that create route ID '1' and run before this file alphabetically. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
… 19/20 After changing route ID from '1' to 'limit-count-rules-1', the etcd key path changes from /apisix/routes/1 to /apisix/routes/limit-count-rules-1. Update error_log patterns in TEST 19 and TEST 20 to match the new path. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Use ngx.say() instead of ngx.print() to include trailing newline - Remove explicit error_code: 201 check to accept both 200 (update) and 201 (create), consistent with other setup tests in this file Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
When rules are used with a custom limit_header (e.g. ai-rate-limiting sets "X-AI-RateLimit-Limit"), the per-rule indexed headers must preserve that base prefix. Before: X-1-RateLimit-Limit (ignored conf.limit_header) After: X-AI-1-RateLimit-Limit (uses conf.limit_header as base) The fix inserts the rule prefix before "RateLimit-" in the configured header name via gsub, so any header base is preserved. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
Summary
This PR enhances the
limit-countplugin with three new capabilities:1. Redis Sentinel backend
Adds a new
redis-sentinelpolicy that connects to Redis through Sentinel for high-availability setups:2. Sliding window algorithm
Adds a
window_typefield (default:fixed) to choose between the existing fixed-window counter and a new sliding-window algorithm:3. Delayed sync (
sync_interval)Adds a
sync_intervalfield forredis,redis-cluster, andredis-sentinelpolicies:-1to disable (default behavior: sync on every request)Changes
limit-count-redis-sentinel.lua,delayed-syncer.lua,util.lua,sliding-window/init.lua,limit-count-redis.lua,limit-count-redis-cluster.lua,limit-count-local.luat/plugin/limit-count-redis-sentinel.t,t/plugin/limit-count-sliding.t,t/plugin/limit-count-redis-delayed-sync.tCompatibility
All existing configurations remain unchanged. New fields are optional with backward-compatible defaults.