-
Notifications
You must be signed in to change notification settings - Fork 1.2k
TT-6075: Update rate limit implementation #7941
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
vladzabolotnyi
merged 76 commits into
master
from
feat/TT-6075/update-rate-limit-header-logic
Apr 20, 2026
Merged
Changes from 68 commits
Commits
Show all changes
76 commits
Select commit
Hold shift + click to select a range
91a05bd
poc
shults 6c59ebd
import fixe
shults c88e5f8
part B poc
shults 8496a19
add backet tests, removed data race
shults 8d0016b
test cover
shults ebda404
spome other tests
shults 64772f8
header sender unit tests
shults 43f45fe
code coverate improvement
shults db1b418
artificial code coverage increase :)
shults 514af40
add tests for limitSentinel
shults 7fe4d97
mock
shults 1f7b9ea
add tests
shults 47d245b
limitRedis tests
shults 547ebce
apply Patrics succestion
shults 70c614a
config loading precedence
shults 0c4d37b
Maciej review
shults 68cd697
poc2
shults 42ccf6d
fix failing unit test
shults 75918ab
fix faling tests
shults 68526b8
merge master and resolve conflicts
945e1b4
feat: add bucket state and checker and update rate limits headers han…
b4d2521
test: update bucket tests with using synctest to avoid flakiness
ae1f5e0
Merge branch 'master' of github.com:TykTechnologies/tyk into feat/TT-…
d949f75
fix: update new bucket state checker with using tokens conversation i…
ee4c0f5
fix: update shouldBlock condition after checking the limiters logic w…
49e4deb
test: adding tests covering rate limit headers logic for rate_limitin…
516b87b
test: add tests covering edge cases for rate limit and quota headers
546f9d8
fix: update reset value for rate_limit at context with unix format
d7807fa
test: add test covering logic with limiters for api mw
fa23666
refactor: extend existing test instad creaing new one
722a77b
refactor: remove redundant test
4ae08d8
feat: add headers removing by rate limit sender to avoid override by …
e7c7855
fix: update test with actually hitting the dynamic handler route
6bc00ea
fix: update condition for limitDRL to avoid cases of returning should…
82cc2fb
feat: add send quotas to cache_mw for striping cached upstream headers
81bd076
Merge branch 'master' of github.com:TykTechnologies/tyk into feat/TT-…
3a46ad6
chore: remove Yarik's highlighting comments
d375f39
chore: update comment
2f2c92d
feat: update condition to always set remaining values to 0 if origina…
5d6aaea
chore: remove Yarik's comment
89dbae2
chore: update script with formatting
dc5f79d
docs: add comments explaining the logic behind RL and Quotas headers …
50a95ff
chore: remove gomock dependency and custom stub because its not used …
a210b75
fix: update mw_org_activity logic with passing nil and add condition …
d485ffb
feat: add condition to write headers for exposing global api limits f…
d692b48
fix: replace "" with "0" in tests after update logic with remaining h…
b50f082
fix: add case for mw_url_rewrite to process checker state int
11ce169
test: add one more eventually to fix flaky test
352b3bc
Revert "test: add one more eventually to fix flaky test"
bd2f515
test: increase time to resolve flaky test
6361bf3
test: update tests with fixes for flaky tests
8b9d695
test: trying to fix flaky test with mutex
e7265f7
test: add idle conn timeout to 10 seconds to check if it helps to fix…
51acb6a
debug: check if rework assertion with > 0 for connections will fix th…
69c9467
debug: adding http handler idle timeout with launching proxies with r…
ad91879
debug: another try with http handler timeouts update
9057bbf
fix: add closing test case server on test and revert changes of faili…
2bcec8a
fix: add unique apiid to avoid key collision on redis
e67607c
fix: add unique key for redis at limitRedis test
157e38e
revert refactoring changes to avoid 100 issues on test file
c8954a5
Merge branch 'master' into feat/TT-6075/update-rate-limit-header-logic
vladzabolotnyi 73a6407
Merge branch 'master' into feat/TT-6075/update-rate-limit-header-logic
vladzabolotnyi aab63f1
feat: replace global enable rl ctx variables with api def check
e11b500
fix: remove enable_context_variables from cli schema
eb72dbe
test: add tests covering logic with attaching rl and quota values to …
840cd11
refactor: move rate_limit_headers sourced to rate_limit config type a…
3b9c0a1
config: replace rl_headers_source with rl_response_headers to make it…
776896d
Merge branch 'master' into feat/TT-6075/update-rate-limit-header-logic
vladzabolotnyi 6751798
docs: update cli schema description of new field
vladzabolotnyi 3f79432
Merge branch 'master' into feat/TT-6075/update-rate-limit-header-logic
vladzabolotnyi 9d44b57
Merge branch 'master' into feat/TT-6075/update-rate-limit-header-logic
vladzabolotnyi 93ef219
Merge branch 'master' into feat/TT-6075/update-rate-limit-header-logic
vladzabolotnyi 36f92b8
Merge branch 'master' into feat/TT-6075/update-rate-limit-header-logic
vladzabolotnyi 739d1ec
Merge branch 'master' into feat/TT-6075/update-rate-limit-header-logic
vladzabolotnyi 4b325f3
Merge branch 'master' into feat/TT-6075/update-rate-limit-header-logic
vladzabolotnyi 93571d1
Merge branch 'master' into feat/TT-6075/update-rate-limit-header-logic
vladzabolotnyi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| package gateway | ||
|
|
||
| import ( | ||
| "net/http" | ||
| "testing" | ||
|
|
||
| "github.com/stretchr/testify/assert" | ||
| "github.com/stretchr/testify/require" | ||
| ) | ||
|
|
||
| func Test_ctxGetOrCreateData(t *testing.T) { | ||
| t.Run("returns data if already exists", func(t *testing.T) { | ||
| req, err := http.NewRequestWithContext(t.Context(), "GET", "/", nil) | ||
| require.NoError(t, err) | ||
|
|
||
| ctxSetData(req, CtxData{"hello": "world0"}) | ||
|
|
||
| assert.Equal(t, CtxData{"hello": "world0"}, ctxGetOrCreateData(req)) | ||
| }) | ||
|
|
||
| t.Run("create new data if not exists", func(t *testing.T) { | ||
| req, err := http.NewRequestWithContext(t.Context(), "GET", "/", nil) | ||
| require.NoError(t, err) | ||
|
|
||
| data1 := ctxGetOrCreateData(req) | ||
| data1["hello"] = "world1" | ||
|
|
||
| data2 := ctxGetOrCreateData(req) | ||
|
|
||
| assert.Equal(t, data1, data2) | ||
| }) | ||
| } |
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.