Skip to content
Snippets Groups Projects
Commit afb69eaa authored by Ming Deng's avatar Ming Deng
Browse files

Add more comments for RejectedExecutionHandler

parent 4d82d8e4
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
......@@ -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
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment