Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
2
22a7f0099
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Summer2022
22a7f0099
Commits
afb69eaa
Commit
afb69eaa
authored
5 years ago
by
Ming Deng
Browse files
Options
Downloads
Patches
Plain Diff
Add more comments for RejectedExecutionHandler
parent
4d82d8e4
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
filter/common/rejected_execution_handler.go
+4
-1
4 additions, 1 deletion
filter/common/rejected_execution_handler.go
filter/impl/execute_limit_filter.go
+3
-1
3 additions, 1 deletion
filter/impl/execute_limit_filter.go
with
7 additions
and
2 deletions
filter/common/rejected_execution_handler.go
+
4
−
1
View file @
afb69eaa
...
...
@@ -22,8 +22,11 @@ import (
)
/**
* If the invocation cannot pass any validation in filter, like ExecuteLimit and TpsLimit,
* If the invocation cannot pass any validation in filter, like ExecuteLimit
Filter
and TpsLimit
Filter
,
* the implementation will be used.
* The common case is that sometimes you want to return the default value when the request was rejected.
* Or you want to be warned if any request was rejected.
* In such situation, implement this interface and register it by invoking extension.SetRejectedExecutionHandler.
*/
type
RejectedExecutionHandler
interface
{
RejectedExecution
(
url
common
.
URL
,
invocation
protocol
.
Invocation
)
protocol
.
Result
...
...
This diff is collapsed.
Click to expand it.
filter/impl/execute_limit_filter.go
+
3
−
1
View file @
afb69eaa
...
...
@@ -58,12 +58,14 @@ func init() {
* - name: "UpdateUser"
* execute.limit: -1, # If the rate<0, the method will be ignored
* - name: "DeleteUser"
* execute.limit.rejected.handle: "customHandler"
* execute.limit.rejected.handle: "customHandler"
# Using the custom handler to do something when the request was rejected.
* - name: "AddUser"
* From the example, the configuration in service-level is 200, and the configuration of method GetUser is 20.
* it means that, the GetUser will be counted separately.
* The configuration of method UpdateUser is -1, so the invocation for it will not be counted.
* So the method DeleteUser and method AddUser will be limited by service-level configuration.
* Sometimes we want to do something, like log the request or return default value when the request is over limitation.
* Then you can implement the RejectedExecutionHandler interface and register it by invoking SetRejectedExecutionHandler.
*/
type
ExecuteLimitFilter
struct
{
executeState
*
concurrent
.
Map
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment