From afb69eaa9ee836f1c5c17dd1fa22caa2bd4a3e80 Mon Sep 17 00:00:00 2001
From: Ming Deng <mindeng@ebay.com>
Date: Mon, 28 Oct 2019 14:09:01 +0800
Subject: [PATCH] Add more comments for RejectedExecutionHandler

---
 filter/common/rejected_execution_handler.go | 5 ++++-
 filter/impl/execute_limit_filter.go         | 4 +++-
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/filter/common/rejected_execution_handler.go b/filter/common/rejected_execution_handler.go
index 61aa0c39e..b993b8444 100644
--- a/filter/common/rejected_execution_handler.go
+++ b/filter/common/rejected_execution_handler.go
@@ -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
diff --git a/filter/impl/execute_limit_filter.go b/filter/impl/execute_limit_filter.go
index fc710af88..156af1b14 100644
--- a/filter/impl/execute_limit_filter.go
+++ b/filter/impl/execute_limit_filter.go
@@ -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
-- 
GitLab