Skip to content
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

Feature: ExecuteLimit Support #246

Merged
merged 6 commits into from
Oct 29, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Add more comments for RejectedExecutionHandler
  • Loading branch information
flycash committed Oct 28, 2019
commit 32f8233e0ffbb75503663a73bac45b0cdd709abf
5 changes: 4 additions & 1 deletion filter/common/rejected_execution_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 ExecuteLimitFilter and TpsLimitFilter,
* 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
Expand Down
4 changes: 3 additions & 1 deletion filter/impl/execute_limit_filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down