Skip to content
Snippets Groups Projects
Commit 9f5afaeb authored by Patrick's avatar Patrick
Browse files

modify filter package

parent 61171b32
No related branches found
No related tags found
No related merge requests found
Showing
with 36 additions and 38 deletions
......@@ -19,12 +19,11 @@ package extension
import (
"github.com/apache/dubbo-go/filter"
"github.com/apache/dubbo-go/filter/common"
)
var (
filters = make(map[string]func() filter.Filter)
rejectedExecutionHandler = make(map[string]func() common.RejectedExecutionHandler)
rejectedExecutionHandler = make(map[string]func() filter.RejectedExecutionHandler)
)
func SetFilter(name string, v func() filter.Filter) {
......@@ -38,11 +37,11 @@ func GetFilter(name string) filter.Filter {
return filters[name]()
}
func SetRejectedExecutionHandler(name string, creator func() common.RejectedExecutionHandler) {
func SetRejectedExecutionHandler(name string, creator func() filter.RejectedExecutionHandler) {
rejectedExecutionHandler[name] = creator
}
func GetRejectedExecutionHandler(name string) common.RejectedExecutionHandler {
func GetRejectedExecutionHandler(name string) filter.RejectedExecutionHandler {
creator, ok := rejectedExecutionHandler[name]
if !ok {
panic("RejectedExecutionHandler for " + name + " is not existing, make sure you have import the package " +
......
......@@ -18,19 +18,19 @@
package extension
import (
"github.com/apache/dubbo-go/filter/impl/tps"
"github.com/apache/dubbo-go/filter"
)
var (
tpsLimitStrategy = make(map[string]tps.TpsLimitStrategyCreator)
tpsLimiter = make(map[string]func() tps.TpsLimiter)
tpsLimitStrategy = make(map[string]filter.TpsLimitStrategyCreator)
tpsLimiter = make(map[string]func() filter.TpsLimiter)
)
func SetTpsLimiter(name string, creator func() tps.TpsLimiter) {
func SetTpsLimiter(name string, creator func() filter.TpsLimiter) {
tpsLimiter[name] = creator
}
func GetTpsLimiter(name string) tps.TpsLimiter {
func GetTpsLimiter(name string) filter.TpsLimiter {
creator, ok := tpsLimiter[name]
if !ok {
panic("TpsLimiter for " + name + " is not existing, make sure you have import the package " +
......@@ -39,11 +39,11 @@ func GetTpsLimiter(name string) tps.TpsLimiter {
return creator()
}
func SetTpsLimitStrategy(name string, creator tps.TpsLimitStrategyCreator) {
func SetTpsLimitStrategy(name string, creator filter.TpsLimitStrategyCreator) {
tpsLimitStrategy[name] = creator
}
func GetTpsLimitStrategyCreator(name string) tps.TpsLimitStrategyCreator {
func GetTpsLimitStrategyCreator(name string) filter.TpsLimitStrategyCreator {
creator, ok := tpsLimitStrategy[name]
if !ok {
panic("TpsLimitStrategy for " + name + " is not existing, make sure you have import the package " +
......
......@@ -18,7 +18,7 @@
// Source: rejected_execution_handler.go
// Package filter is a generated GoMock package.
package impl
package common
import (
reflect "reflect"
......
......@@ -15,9 +15,10 @@
* limitations under the License.
*/
package impl
package common
import (
"github.com/apache/dubbo-go/filter"
"sync"
)
......@@ -26,7 +27,6 @@ import (
"github.com/apache/dubbo-go/common/constant"
"github.com/apache/dubbo-go/common/extension"
"github.com/apache/dubbo-go/common/logger"
filterCommon "github.com/apache/dubbo-go/filter/common"
"github.com/apache/dubbo-go/protocol"
)
......@@ -61,7 +61,7 @@ func (handler *OnlyLogRejectedExecutionHandler) RejectedExecution(url common.URL
return &protocol.RPCResult{}
}
func GetOnlyLogRejectedExecutionHandler() filterCommon.RejectedExecutionHandler {
func GetOnlyLogRejectedExecutionHandler() filter.RejectedExecutionHandler {
onlyLogHandlerOnce.Do(func() {
onlyLogHandlerInstance = &OnlyLogRejectedExecutionHandler{}
})
......
......@@ -15,7 +15,7 @@
* limitations under the License.
*/
package impl
package common
import (
"net/url"
......
......@@ -15,7 +15,7 @@
* limitations under the License.
*/
package impl
package filter
import (
"os"
......
......@@ -15,7 +15,7 @@
* limitations under the License.
*/
package impl
package filter
import (
"context"
......
......@@ -15,7 +15,7 @@
* limitations under the License.
*/
package impl
package filter
import (
"github.com/apache/dubbo-go/common/extension"
......
......@@ -15,7 +15,7 @@
* limitations under the License.
*/
package impl
package filter
import (
"github.com/apache/dubbo-go/common/constant"
......
......@@ -15,7 +15,7 @@
* limitations under the License.
*/
package impl
package filter
import (
"testing"
......
......@@ -15,7 +15,7 @@
* limitations under the License.
*/
package impl
package filter
import (
"strconv"
......@@ -32,7 +32,7 @@ import (
"github.com/apache/dubbo-go/common/extension"
"github.com/apache/dubbo-go/common/logger"
"github.com/apache/dubbo-go/filter"
_ "github.com/apache/dubbo-go/filter/common/impl"
_ "github.com/apache/dubbo-go/filter/common"
"github.com/apache/dubbo-go/protocol"
)
......
......@@ -15,7 +15,7 @@
* limitations under the License.
*/
package impl
package filter
import (
"net/url"
......
......@@ -15,7 +15,7 @@
* limitations under the License.
*/
package impl
package filter
import (
"reflect"
......
......@@ -15,7 +15,7 @@
* limitations under the License.
*/
package impl
package filter
import (
"reflect"
......
......@@ -15,7 +15,7 @@
* limitations under the License.
*/
package impl
package filter
import (
"reflect"
......
......@@ -15,7 +15,7 @@
* limitations under the License.
*/
package impl
package filter
import (
"context"
......
......@@ -15,7 +15,7 @@
* limitations under the License.
*/
package impl
package filter
import (
"sync/atomic"
......@@ -27,7 +27,6 @@ import (
"github.com/apache/dubbo-go/common/logger"
"github.com/apache/dubbo-go/config"
"github.com/apache/dubbo-go/filter"
"github.com/apache/dubbo-go/filter/common"
"github.com/apache/dubbo-go/protocol"
)
......@@ -78,7 +77,7 @@ func (gf *gracefulShutdownFilter) rejectNewRequest() bool {
return gf.shutdownConfig.RejectRequest
}
func (gf *gracefulShutdownFilter) getRejectHandler() common.RejectedExecutionHandler {
func (gf *gracefulShutdownFilter) getRejectHandler() filter.RejectedExecutionHandler {
handler := constant.DEFAULT_KEY
if gf.shutdownConfig != nil && len(gf.shutdownConfig.RejectRequestHandler) > 0 {
handler = gf.shutdownConfig.RejectRequestHandler
......
......@@ -15,9 +15,11 @@
* limitations under the License.
*/
package impl
package filter
import (
"github.com/apache/dubbo-go/filter"
common2 "github.com/apache/dubbo-go/filter/common"
"net/url"
"testing"
)
......@@ -31,8 +33,6 @@ import (
"github.com/apache/dubbo-go/common/constant"
"github.com/apache/dubbo-go/common/extension"
"github.com/apache/dubbo-go/config"
filterCommon "github.com/apache/dubbo-go/filter/common"
"github.com/apache/dubbo-go/filter/common/impl"
"github.com/apache/dubbo-go/protocol"
"github.com/apache/dubbo-go/protocol/invocation"
)
......@@ -66,8 +66,8 @@ func TestGenericFilter_Invoke(t *testing.T) {
assert.True(t, shutdownFilter.rejectNewRequest())
result = shutdownFilter.OnResponse(nil, protocol.NewBaseInvoker(*invokeUrl), invoc)
rejectHandler := &impl.OnlyLogRejectedExecutionHandler{}
extension.SetRejectedExecutionHandler("mock", func() filterCommon.RejectedExecutionHandler {
rejectHandler := &common2.OnlyLogRejectedExecutionHandler{}
extension.SetRejectedExecutionHandler("mock", func() filter.RejectedExecutionHandler {
return rejectHandler
})
assert.True(t, providerConfig.ShutdownConfig.RequestsFinished)
......
......@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package impl
package filter
import (
"fmt"
......
......@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package impl
package filter
import (
"regexp"
......
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