-
Notifications
You must be signed in to change notification settings - Fork 721
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
pkg: delete config when QPS and concurrency are both deleted #8653
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
12363e2
delete config when QPS and concurrency set to 0
rleungx a78b7ab
refactor the status
rleungx cf11dfe
rollback when updating failed
rleungx 15bfdc5
fix
rleungx e681eab
fix
rleungx 87b93a7
fix
rleungx c959207
fix metrics
rleungx 4109a9a
Merge branch 'master' into case-delete
ti-chi-bot[bot] 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 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 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 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 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 |
---|---|---|
|
@@ -20,18 +20,12 @@ type UpdateStatus uint32 | |
// Flags for limiter. | ||
const ( | ||
eps float64 = 1e-8 | ||
// QPSNoChange shows that limiter's config isn't changed. | ||
QPSNoChange UpdateStatus = 1 << iota | ||
// QPSChanged shows that limiter's config is changed and not deleted. | ||
QPSChanged | ||
// QPSDeleted shows that limiter's config is deleted. | ||
QPSDeleted | ||
// ConcurrencyNoChange shows that limiter's config isn't changed. | ||
ConcurrencyNoChange | ||
// ConcurrencyChanged shows that limiter's config is changed and not deleted. | ||
ConcurrencyChanged | ||
// ConcurrencyDeleted shows that limiter's config is deleted. | ||
ConcurrencyDeleted | ||
|
||
LimiterNotChanged UpdateStatus = 1 << iota | ||
// LimiterUpdated shows that limiter's config is updated. | ||
LimiterUpdated | ||
// LimiterDeleted shows that limiter's config is deleted. | ||
LimiterDeleted | ||
// InAllowList shows that limiter's config isn't changed because it is in in allow list. | ||
InAllowList | ||
) | ||
|
@@ -45,7 +39,7 @@ type Option func(string, *Controller) UpdateStatus | |
func AddLabelAllowList() Option { | ||
return func(label string, l *Controller) UpdateStatus { | ||
l.labelAllowList[label] = struct{}{} | ||
return 0 | ||
return InAllowList | ||
} | ||
} | ||
|
||
|
@@ -73,11 +67,11 @@ func UpdateQPSLimiter(limit float64, burst int) Option { | |
|
||
// UpdateDimensionConfig creates QPS limiter and concurrency limiter for a given label by config if it doesn't exist. | ||
func UpdateDimensionConfig(cfg *DimensionConfig) Option { | ||
return func(label string, l *Controller) UpdateStatus { | ||
if _, allow := l.labelAllowList[label]; allow { | ||
return func(label string, c *Controller) UpdateStatus { | ||
if _, allow := c.labelAllowList[label]; allow { | ||
return InAllowList | ||
} | ||
lim, _ := l.limiters.LoadOrStore(label, newLimiter()) | ||
lim, _ := c.limiters.LoadOrStore(label, newLimiter()) | ||
return lim.(*limiter).updateDimensionConfig(cfg) | ||
} | ||
} | ||
|
@@ -89,6 +83,6 @@ func InitLimiter() Option { | |
return InAllowList | ||
} | ||
l.limiters.LoadOrStore(label, newLimiter()) | ||
return ConcurrencyChanged | ||
return LimiterNotChanged | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Has there been a change here, as expected? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, the limit is not changed when we initialize the limiter. |
||
} | ||
} |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be
LimiterNoChanged
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, LimiterDeleted indicates that we should remove the corresponding label from the config.