diff --git a/common/extension/filter.go b/common/extension/filter.go index 93f7f8cf7ccc4108fe1120b685fad36a2f9f83df..0b5c4b40aa78f7ea489a306f4a52efbb07243b41 100644 --- a/common/extension/filter.go +++ b/common/extension/filter.go @@ -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 " + diff --git a/common/extension/tps_limit.go b/common/extension/tps_limit.go index 151c33ad5e64ffa4059489e2cbcfae6f2e823328..8c131fafa3159047d25b43ae0a57d674418a2170 100644 --- a/common/extension/tps_limit.go +++ b/common/extension/tps_limit.go @@ -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 " + diff --git a/filter/common/impl/rejected_execution_handler_mock.go b/filter/common/rejected_execution_handler_mock.go similarity index 99% rename from filter/common/impl/rejected_execution_handler_mock.go rename to filter/common/rejected_execution_handler_mock.go index dace1894668d3a4a154a87bfbdbcc860a97a11ec..a5631af9f7600cae772437877b1ac9139655cc5f 100644 --- a/filter/common/impl/rejected_execution_handler_mock.go +++ b/filter/common/rejected_execution_handler_mock.go @@ -18,7 +18,7 @@ // Source: rejected_execution_handler.go // Package filter is a generated GoMock package. -package impl +package common import ( reflect "reflect" diff --git a/filter/common/impl/rejected_execution_handler_only_log.go b/filter/common/rejected_execution_handler_only_log.go similarity index 93% rename from filter/common/impl/rejected_execution_handler_only_log.go rename to filter/common/rejected_execution_handler_only_log.go index 8943433af1ba908fc834740163df78e3b2b6443a..65abe677f129fa2fbe412c7e3ea2b23de2f1ade6 100644 --- a/filter/common/impl/rejected_execution_handler_only_log.go +++ b/filter/common/rejected_execution_handler_only_log.go @@ -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{} }) diff --git a/filter/common/impl/rejected_execution_handler_only_log_test.go b/filter/common/rejected_execution_handler_only_log_test.go similarity index 98% rename from filter/common/impl/rejected_execution_handler_only_log_test.go rename to filter/common/rejected_execution_handler_only_log_test.go index da54d8a106338dd4f21f9b01e66b031e3c311e01..0efc3d813771577d38fd5e7989255fc097b49a08 100644 --- a/filter/common/impl/rejected_execution_handler_only_log_test.go +++ b/filter/common/rejected_execution_handler_only_log_test.go @@ -15,7 +15,7 @@ * limitations under the License. */ -package impl +package common import ( "net/url" diff --git a/filter/impl/access_log_filter.go b/filter/filter/access_log_filter.go similarity index 99% rename from filter/impl/access_log_filter.go rename to filter/filter/access_log_filter.go index 89fa34952f99057f1d8bb35794a57f9905f5f169..cce2c5050fcbc60bc45b7bc2751685a8d9677b76 100644 --- a/filter/impl/access_log_filter.go +++ b/filter/filter/access_log_filter.go @@ -15,7 +15,7 @@ * limitations under the License. */ -package impl +package filter import ( "os" diff --git a/filter/impl/access_log_filter_test.go b/filter/filter/access_log_filter_test.go similarity index 99% rename from filter/impl/access_log_filter_test.go rename to filter/filter/access_log_filter_test.go index 834d531f05f952c41abfe8e1c56c20c0285926b8..2c17021a9f17d3d99c48e5763087c0b03b490b93 100644 --- a/filter/impl/access_log_filter_test.go +++ b/filter/filter/access_log_filter_test.go @@ -15,7 +15,7 @@ * limitations under the License. */ -package impl +package filter import ( "context" diff --git a/filter/impl/active_filter.go b/filter/filter/active_filter.go similarity index 99% rename from filter/impl/active_filter.go rename to filter/filter/active_filter.go index 36a4e1a767ab7170ce8e5bebf2cfa4403f6ad4ff..e0f73c2b2facd53b23e491be2e5b123b5d33087d 100644 --- a/filter/impl/active_filter.go +++ b/filter/filter/active_filter.go @@ -15,7 +15,7 @@ * limitations under the License. */ -package impl +package filter import ( "github.com/apache/dubbo-go/common/extension" diff --git a/filter/impl/echo_filter.go b/filter/filter/echo_filter.go similarity index 99% rename from filter/impl/echo_filter.go rename to filter/filter/echo_filter.go index 18e42c8cb2b15acb27573c5e24f11a8b69e0d496..1515c0a99c77d7a4d9af93e141cbed9b529158d7 100644 --- a/filter/impl/echo_filter.go +++ b/filter/filter/echo_filter.go @@ -15,7 +15,7 @@ * limitations under the License. */ -package impl +package filter import ( "github.com/apache/dubbo-go/common/constant" diff --git a/filter/impl/echo_filter_test.go b/filter/filter/echo_filter_test.go similarity index 98% rename from filter/impl/echo_filter_test.go rename to filter/filter/echo_filter_test.go index e2e592974701ad18c5b01e884485c022ee2320b8..d57d54329f52955d283366f6edc1376a1a474bde 100644 --- a/filter/impl/echo_filter_test.go +++ b/filter/filter/echo_filter_test.go @@ -15,7 +15,7 @@ * limitations under the License. */ -package impl +package filter import ( "testing" diff --git a/filter/impl/execute_limit_filter.go b/filter/filter/execute_limit_filter.go similarity index 98% rename from filter/impl/execute_limit_filter.go rename to filter/filter/execute_limit_filter.go index 156af1b140283dd76c4867ca26e9b42ce8eb25c0..4b5ea7491c19a726f1d90b7588ac5a480cd38590 100644 --- a/filter/impl/execute_limit_filter.go +++ b/filter/filter/execute_limit_filter.go @@ -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" ) diff --git a/filter/impl/execute_limit_filter_test.go b/filter/filter/execute_limit_filter_test.go similarity index 99% rename from filter/impl/execute_limit_filter_test.go rename to filter/filter/execute_limit_filter_test.go index 5d729c0e6a1205902856eccfa6aa96b0bee0e790..326b13677b157fbba2495caf5699c246d0d62879 100644 --- a/filter/impl/execute_limit_filter_test.go +++ b/filter/filter/execute_limit_filter_test.go @@ -15,7 +15,7 @@ * limitations under the License. */ -package impl +package filter import ( "net/url" diff --git a/filter/impl/generic_filter.go b/filter/filter/generic_filter.go similarity index 99% rename from filter/impl/generic_filter.go rename to filter/filter/generic_filter.go index 35aadb11a444bda56109e238b17267f71ec2606b..f15449520d4a3d69a89cec2ce195114934e14211 100644 --- a/filter/impl/generic_filter.go +++ b/filter/filter/generic_filter.go @@ -15,7 +15,7 @@ * limitations under the License. */ -package impl +package filter import ( "reflect" diff --git a/filter/impl/generic_filter_test.go b/filter/filter/generic_filter_test.go similarity index 99% rename from filter/impl/generic_filter_test.go rename to filter/filter/generic_filter_test.go index 9797c40df1f57017241675013620a53320e475ad..d5298adbd404d7a525bf66ef248cf54b525a6647 100644 --- a/filter/impl/generic_filter_test.go +++ b/filter/filter/generic_filter_test.go @@ -15,7 +15,7 @@ * limitations under the License. */ -package impl +package filter import ( "reflect" diff --git a/filter/impl/generic_service_filter.go b/filter/filter/generic_service_filter.go similarity index 99% rename from filter/impl/generic_service_filter.go rename to filter/filter/generic_service_filter.go index 2fde925d66a89a5f8bbf208d2f72362d2cbeab89..514a51f0b0f4c5d16109b97f74d1095e1842f658 100644 --- a/filter/impl/generic_service_filter.go +++ b/filter/filter/generic_service_filter.go @@ -15,7 +15,7 @@ * limitations under the License. */ -package impl +package filter import ( "reflect" diff --git a/filter/impl/generic_service_filter_test.go b/filter/filter/generic_service_filter_test.go similarity index 99% rename from filter/impl/generic_service_filter_test.go rename to filter/filter/generic_service_filter_test.go index 89898694c267ad5a84814651b16d3ff9bcfc871a..599a6a66d07ee0ed95545680ccb195f1a2fdeb68 100644 --- a/filter/impl/generic_service_filter_test.go +++ b/filter/filter/generic_service_filter_test.go @@ -15,7 +15,7 @@ * limitations under the License. */ -package impl +package filter import ( "context" diff --git a/filter/impl/graceful_shutdown_filter.go b/filter/filter/graceful_shutdown_filter.go similarity index 95% rename from filter/impl/graceful_shutdown_filter.go rename to filter/filter/graceful_shutdown_filter.go index b912ea88e4ba4741b7d7fe36b8bbd3ba158abe63..c682c7ef79deef2e66178cf1c43ec87992e960dc 100644 --- a/filter/impl/graceful_shutdown_filter.go +++ b/filter/filter/graceful_shutdown_filter.go @@ -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 diff --git a/filter/impl/graceful_shutdown_filter_test.go b/filter/filter/graceful_shutdown_filter_test.go similarity index 89% rename from filter/impl/graceful_shutdown_filter_test.go rename to filter/filter/graceful_shutdown_filter_test.go index 21da167ea0f201ea357c51cab0ecb4f8ebec0957..38430a5d1eb1302436efd3f4d3e5f9b9d93035ce 100644 --- a/filter/impl/graceful_shutdown_filter_test.go +++ b/filter/filter/graceful_shutdown_filter_test.go @@ -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) diff --git a/filter/impl/hystrix_filter.go b/filter/filter/hystrix_filter.go similarity index 99% rename from filter/impl/hystrix_filter.go rename to filter/filter/hystrix_filter.go index 3fd9f87168616b69d5ec72460767890d6956c154..a7c57b4dd6c4a50f8ff90c6e22ff27cc5ef6658e 100644 --- a/filter/impl/hystrix_filter.go +++ b/filter/filter/hystrix_filter.go @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package impl +package filter import ( "fmt" diff --git a/filter/impl/hystrix_filter_test.go b/filter/filter/hystrix_filter_test.go similarity index 99% rename from filter/impl/hystrix_filter_test.go rename to filter/filter/hystrix_filter_test.go index d3a5183ede25d8a325bb1c73020edddd2ffbc638..37432940300e558eee971448c5829b2d6c8f2696 100644 --- a/filter/impl/hystrix_filter_test.go +++ b/filter/filter/hystrix_filter_test.go @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package impl +package filter import ( "regexp" diff --git a/filter/impl/token_filter.go b/filter/filter/token_filter.go similarity index 99% rename from filter/impl/token_filter.go rename to filter/filter/token_filter.go index d10dff5b761d0fbe40ff3a14a93ee8962d000e02..07b80f3402dbd63243b1c48e2d98c80a1f704362 100644 --- a/filter/impl/token_filter.go +++ b/filter/filter/token_filter.go @@ -15,7 +15,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package impl +package filter import ( "strings" diff --git a/filter/impl/token_filter_test.go b/filter/filter/token_filter_test.go similarity index 99% rename from filter/impl/token_filter_test.go rename to filter/filter/token_filter_test.go index 1473f274037699260725ff9ebb1b3d1377efb326..4434865de7918e41720fdd74eace32e9483901b6 100644 --- a/filter/impl/token_filter_test.go +++ b/filter/filter/token_filter_test.go @@ -15,7 +15,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package impl +package filter import ( "net/url" diff --git a/filter/impl/tps_limit_filter.go b/filter/filter/tps_limit_filter.go similarity index 95% rename from filter/impl/tps_limit_filter.go rename to filter/filter/tps_limit_filter.go index 3cb7381c8616abd61fe2ac306b59694a92715dda..ccccec00d4741481534185eaab290fc717864bd8 100644 --- a/filter/impl/tps_limit_filter.go +++ b/filter/filter/tps_limit_filter.go @@ -15,15 +15,15 @@ * limitations under the License. */ -package impl +package filter import ( "github.com/apache/dubbo-go/common/constant" "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/impl/tps/impl" + _ "github.com/apache/dubbo-go/filter/common" + _ "github.com/apache/dubbo-go/filter/tps" "github.com/apache/dubbo-go/protocol" ) diff --git a/filter/impl/tps_limit_filter_test.go b/filter/filter/tps_limit_filter_test.go similarity index 84% rename from filter/impl/tps_limit_filter_test.go rename to filter/filter/tps_limit_filter_test.go index debdbd00dec97ed67d789bfc45103993c014ab4a..d4353bb7d1da6e26c51b0f1a33f7fa5ebf9e6f84 100644 --- a/filter/impl/tps_limit_filter_test.go +++ b/filter/filter/tps_limit_filter_test.go @@ -15,9 +15,12 @@ * limitations under the License. */ -package impl +package filter import ( + "github.com/apache/dubbo-go/filter" + common2 "github.com/apache/dubbo-go/filter/common" + "github.com/apache/dubbo-go/filter/tps" "net/url" "testing" ) @@ -31,10 +34,6 @@ import ( "github.com/apache/dubbo-go/common" "github.com/apache/dubbo-go/common/constant" "github.com/apache/dubbo-go/common/extension" - filterCommon "github.com/apache/dubbo-go/filter/common" - filterCommonImpl "github.com/apache/dubbo-go/filter/common/impl" - "github.com/apache/dubbo-go/filter/impl/tps" - "github.com/apache/dubbo-go/filter/impl/tps/impl" "github.com/apache/dubbo-go/protocol" "github.com/apache/dubbo-go/protocol/invocation" ) @@ -56,9 +55,9 @@ func TestTpsLimitFilter_Invoke_With_No_TpsLimiter(t *testing.T) { func TestGenericFilter_Invoke_With_Default_TpsLimiter(t *testing.T) { ctrl := gomock.NewController(t) defer ctrl.Finish() - mockLimiter := impl.NewMockTpsLimiter(ctrl) + mockLimiter := tps.NewMockTpsLimiter(ctrl) mockLimiter.EXPECT().IsAllowable(gomock.Any(), gomock.Any()).Return(true).Times(1) - extension.SetTpsLimiter(constant.DEFAULT_KEY, func() tps.TpsLimiter { + extension.SetTpsLimiter(constant.DEFAULT_KEY, func() filter.TpsLimiter { return mockLimiter }) @@ -77,17 +76,17 @@ func TestGenericFilter_Invoke_With_Default_TpsLimiter(t *testing.T) { func TestGenericFilter_Invoke_With_Default_TpsLimiter_Not_Allow(t *testing.T) { ctrl := gomock.NewController(t) defer ctrl.Finish() - mockLimiter := impl.NewMockTpsLimiter(ctrl) + mockLimiter := tps.NewMockTpsLimiter(ctrl) mockLimiter.EXPECT().IsAllowable(gomock.Any(), gomock.Any()).Return(false).Times(1) - extension.SetTpsLimiter(constant.DEFAULT_KEY, func() tps.TpsLimiter { + extension.SetTpsLimiter(constant.DEFAULT_KEY, func() filter.TpsLimiter { return mockLimiter }) mockResult := &protocol.RPCResult{} - mockRejectedHandler := filterCommonImpl.NewMockRejectedExecutionHandler(ctrl) + mockRejectedHandler := common2.NewMockRejectedExecutionHandler(ctrl) mockRejectedHandler.EXPECT().RejectedExecution(gomock.Any(), gomock.Any()).Return(mockResult).Times(1) - extension.SetRejectedExecutionHandler(constant.DEFAULT_KEY, func() filterCommon.RejectedExecutionHandler { + extension.SetRejectedExecutionHandler(constant.DEFAULT_KEY, func() filter.RejectedExecutionHandler { return mockRejectedHandler }) diff --git a/filter/common/rejected_execution_handler.go b/filter/rejected_execution_handler.go similarity index 98% rename from filter/common/rejected_execution_handler.go rename to filter/rejected_execution_handler.go index b993b8444c14c13ce9a8861c113dc02ca5fd335a..ce95b54b14d01e0aec6f6089799df8378b5bcca5 100644 --- a/filter/common/rejected_execution_handler.go +++ b/filter/rejected_execution_handler.go @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package common +package filter import ( "github.com/apache/dubbo-go/common" diff --git a/filter/impl/tps/impl/tps_limit_fix_window_strategy.go b/filter/tps/tps_limit_fix_window_strategy.go similarity index 96% rename from filter/impl/tps/impl/tps_limit_fix_window_strategy.go rename to filter/tps/tps_limit_fix_window_strategy.go index 285ecfa658cf838cc1140ba716bd72e1976b86fe..b69c567ffe777b02dcba3f36d437f0e9dfda52ff 100644 --- a/filter/impl/tps/impl/tps_limit_fix_window_strategy.go +++ b/filter/tps/tps_limit_fix_window_strategy.go @@ -15,9 +15,10 @@ * limitations under the License. */ -package impl +package tps import ( + "github.com/apache/dubbo-go/filter" "sync/atomic" "time" ) @@ -25,7 +26,6 @@ import ( import ( "github.com/apache/dubbo-go/common/constant" "github.com/apache/dubbo-go/common/extension" - "github.com/apache/dubbo-go/filter/impl/tps" ) const ( @@ -79,7 +79,7 @@ func (impl *FixedWindowTpsLimitStrategyImpl) IsAllowable() bool { type fixedWindowStrategyCreator struct{} -func (creator *fixedWindowStrategyCreator) Create(rate int, interval int) tps.TpsLimitStrategy { +func (creator *fixedWindowStrategyCreator) Create(rate int, interval int) filter.TpsLimitStrategy { return &FixedWindowTpsLimitStrategyImpl{ rate: int32(rate), interval: int64(interval) * int64(time.Millisecond), // convert to ns diff --git a/filter/impl/tps/impl/tps_limit_fix_window_strategy_test.go b/filter/tps/tps_limit_fix_window_strategy_test.go similarity index 99% rename from filter/impl/tps/impl/tps_limit_fix_window_strategy_test.go rename to filter/tps/tps_limit_fix_window_strategy_test.go index 7ef539ed3b2b93da5c56a05f606e75282226d1ef..5eaf2f707dcc9dd6cf325988242623dd5161c1a8 100644 --- a/filter/impl/tps/impl/tps_limit_fix_window_strategy_test.go +++ b/filter/tps/tps_limit_fix_window_strategy_test.go @@ -15,7 +15,7 @@ * limitations under the License. */ -package impl +package tps import ( "testing" diff --git a/filter/impl/tps/impl/tps_limit_sliding_window_strategy.go b/filter/tps/tps_limit_sliding_window_strategy.go similarity index 96% rename from filter/impl/tps/impl/tps_limit_sliding_window_strategy.go rename to filter/tps/tps_limit_sliding_window_strategy.go index d1a5db6e259ffa63282065f881f6cc8360c8d25b..ec2afe6021c8b9b02f579ac16c86d8d0eb8f027b 100644 --- a/filter/impl/tps/impl/tps_limit_sliding_window_strategy.go +++ b/filter/tps/tps_limit_sliding_window_strategy.go @@ -15,17 +15,17 @@ * limitations under the License. */ -package impl +package tps import ( "container/list" + "github.com/apache/dubbo-go/filter" "sync" "time" ) import ( "github.com/apache/dubbo-go/common/extension" - "github.com/apache/dubbo-go/filter/impl/tps" ) func init() { @@ -82,7 +82,7 @@ func (impl *SlidingWindowTpsLimitStrategyImpl) IsAllowable() bool { type slidingWindowStrategyCreator struct{} -func (creator *slidingWindowStrategyCreator) Create(rate int, interval int) tps.TpsLimitStrategy { +func (creator *slidingWindowStrategyCreator) Create(rate int, interval int) filter.TpsLimitStrategy { return &SlidingWindowTpsLimitStrategyImpl{ rate: rate, interval: int64(interval) * int64(time.Millisecond), diff --git a/filter/impl/tps/impl/tps_limit_sliding_window_strategy_test.go b/filter/tps/tps_limit_sliding_window_strategy_test.go similarity index 99% rename from filter/impl/tps/impl/tps_limit_sliding_window_strategy_test.go rename to filter/tps/tps_limit_sliding_window_strategy_test.go index 075f1d9d2be2d18edfee7dc8691b71da65f5da45..57342d1c443993c49c6124f0ef28dae5ebb203e8 100644 --- a/filter/impl/tps/impl/tps_limit_sliding_window_strategy_test.go +++ b/filter/tps/tps_limit_sliding_window_strategy_test.go @@ -15,7 +15,7 @@ * limitations under the License. */ -package impl +package tps import ( "testing" diff --git a/filter/impl/tps/impl/tps_limit_strategy_mock.go b/filter/tps/tps_limit_strategy_mock.go similarity index 99% rename from filter/impl/tps/impl/tps_limit_strategy_mock.go rename to filter/tps/tps_limit_strategy_mock.go index a653fb287a2d89d8c6151889ca14b4b7b4832505..72c658fb9a5d48b6080900a4645d318dfd2b0c21 100644 --- a/filter/impl/tps/impl/tps_limit_strategy_mock.go +++ b/filter/tps/tps_limit_strategy_mock.go @@ -18,7 +18,7 @@ // Source: tps_limit_strategy.go // Package filter is a generated GoMock package. -package impl +package tps import ( gomock "github.com/golang/mock/gomock" diff --git a/filter/impl/tps/impl/tps_limit_thread_safe_fix_window_strategy.go b/filter/tps/tps_limit_thread_safe_fix_window_strategy.go similarity index 95% rename from filter/impl/tps/impl/tps_limit_thread_safe_fix_window_strategy.go rename to filter/tps/tps_limit_thread_safe_fix_window_strategy.go index 9a1b21a3349845e32cb0fe38b07a7f932ec4f454..279c3b0034e7ad02fb7b515d0ede132334031f2c 100644 --- a/filter/impl/tps/impl/tps_limit_thread_safe_fix_window_strategy.go +++ b/filter/tps/tps_limit_thread_safe_fix_window_strategy.go @@ -15,15 +15,15 @@ * limitations under the License. */ -package impl +package tps import ( + "github.com/apache/dubbo-go/filter" "sync" ) import ( "github.com/apache/dubbo-go/common/extension" - "github.com/apache/dubbo-go/filter/impl/tps" ) func init() { @@ -62,7 +62,7 @@ type threadSafeFixedWindowStrategyCreator struct { fixedWindowStrategyCreator *fixedWindowStrategyCreator } -func (creator *threadSafeFixedWindowStrategyCreator) Create(rate int, interval int) tps.TpsLimitStrategy { +func (creator *threadSafeFixedWindowStrategyCreator) Create(rate int, interval int) filter.TpsLimitStrategy { fixedWindowStrategy := creator.fixedWindowStrategyCreator.Create(rate, interval).(*FixedWindowTpsLimitStrategyImpl) return &ThreadSafeFixedWindowTpsLimitStrategyImpl{ fixedWindow: fixedWindowStrategy, diff --git a/filter/impl/tps/impl/tps_limit_thread_safe_fix_window_strategy_test.go b/filter/tps/tps_limit_thread_safe_fix_window_strategy_test.go similarity index 99% rename from filter/impl/tps/impl/tps_limit_thread_safe_fix_window_strategy_test.go rename to filter/tps/tps_limit_thread_safe_fix_window_strategy_test.go index 129493962403e0028b09f9646054fda236c99ff7..90cd15201cd71aafcc50a1dfb801ece7a5dee26a 100644 --- a/filter/impl/tps/impl/tps_limit_thread_safe_fix_window_strategy_test.go +++ b/filter/tps/tps_limit_thread_safe_fix_window_strategy_test.go @@ -15,7 +15,7 @@ * limitations under the License. */ -package impl +package tps import ( "testing" diff --git a/filter/impl/tps/impl/tps_limiter_method_service.go b/filter/tps/tps_limiter_method_service.go similarity index 96% rename from filter/impl/tps/impl/tps_limiter_method_service.go rename to filter/tps/tps_limiter_method_service.go index 426ae5994867c5a09653641870ebcef531c0d43c..11137b784d356df5e659e4bf66296fec6f762719 100644 --- a/filter/impl/tps/impl/tps_limiter_method_service.go +++ b/filter/tps/tps_limiter_method_service.go @@ -14,10 +14,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package impl +package tps import ( "fmt" + "github.com/apache/dubbo-go/filter" "strconv" "sync" ) @@ -30,7 +31,6 @@ import ( "github.com/apache/dubbo-go/common" "github.com/apache/dubbo-go/common/constant" "github.com/apache/dubbo-go/common/extension" - "github.com/apache/dubbo-go/filter/impl/tps" "github.com/apache/dubbo-go/protocol" ) @@ -127,7 +127,7 @@ func (limiter MethodServiceTpsLimiterImpl) IsAllowable(url common.URL, invocatio limitState, found := limiter.tpsState.Load(limitTarget) if found { - return limitState.(tps.TpsLimitStrategy).IsAllowable() + return limitState.(filter.TpsLimitStrategy).IsAllowable() } limitRate := getLimitConfig(methodLimitRateConfig, url, invocation, @@ -149,7 +149,7 @@ func (limiter MethodServiceTpsLimiterImpl) IsAllowable(url common.URL, invocatio url.GetParam(constant.TPS_LIMIT_STRATEGY_KEY, constant.DEFAULT_KEY)) limitStateCreator := extension.GetTpsLimitStrategyCreator(limitStrategyConfig) limitState, _ = limiter.tpsState.LoadOrStore(limitTarget, limitStateCreator.Create(int(limitRate), int(limitInterval))) - return limitState.(tps.TpsLimitStrategy).IsAllowable() + return limitState.(filter.TpsLimitStrategy).IsAllowable() } func getLimitConfig(methodLevelConfig string, @@ -178,7 +178,7 @@ func getLimitConfig(methodLevelConfig string, var methodServiceTpsLimiterInstance *MethodServiceTpsLimiterImpl var methodServiceTpsLimiterOnce sync.Once -func GetMethodServiceTpsLimiter() tps.TpsLimiter { +func GetMethodServiceTpsLimiter() filter.TpsLimiter { methodServiceTpsLimiterOnce.Do(func() { methodServiceTpsLimiterInstance = &MethodServiceTpsLimiterImpl{ tpsState: concurrent.NewMap(), diff --git a/filter/impl/tps/impl/tps_limiter_method_service_test.go b/filter/tps/tps_limiter_method_service_test.go similarity index 97% rename from filter/impl/tps/impl/tps_limiter_method_service_test.go rename to filter/tps/tps_limiter_method_service_test.go index e747d4682d0a8bdee03da6f012fb76b7bd1e02af..80e5797d50435e2284d98c6b2b761ac35c0cd55c 100644 --- a/filter/impl/tps/impl/tps_limiter_method_service_test.go +++ b/filter/tps/tps_limiter_method_service_test.go @@ -15,9 +15,10 @@ * limitations under the License. */ -package impl +package tps import ( + "github.com/apache/dubbo-go/filter" "net/url" "testing" ) @@ -30,7 +31,6 @@ import ( "github.com/apache/dubbo-go/common" "github.com/apache/dubbo-go/common/constant" "github.com/apache/dubbo-go/common/extension" - "github.com/apache/dubbo-go/filter/impl/tps" "github.com/apache/dubbo-go/protocol/invocation" ) @@ -144,10 +144,10 @@ type mockStrategyCreator struct { rate int interval int t *testing.T - strategy tps.TpsLimitStrategy + strategy filter.TpsLimitStrategy } -func (creator *mockStrategyCreator) Create(rate int, interval int) tps.TpsLimitStrategy { +func (creator *mockStrategyCreator) Create(rate int, interval int) filter.TpsLimitStrategy { assert.Equal(creator.t, creator.rate, rate) assert.Equal(creator.t, creator.interval, interval) return creator.strategy diff --git a/filter/impl/tps/impl/tps_limiter_mock.go b/filter/tps/tps_limiter_mock.go similarity index 99% rename from filter/impl/tps/impl/tps_limiter_mock.go rename to filter/tps/tps_limiter_mock.go index acd3a15d18baf10838faf57e141afe1711f0aebb..463b0988acbeb17a967c9803337a61c4914bce42 100644 --- a/filter/impl/tps/impl/tps_limiter_mock.go +++ b/filter/tps/tps_limiter_mock.go @@ -18,7 +18,7 @@ // Source: tps_limiter.go // Package filter is a generated GoMock package. -package impl +package tps import ( reflect "reflect" diff --git a/filter/impl/tps/tps_limit_strategy.go b/filter/tps_limit_strategy.go similarity index 98% rename from filter/impl/tps/tps_limit_strategy.go rename to filter/tps_limit_strategy.go index c55f008a09b3743f728ab0506c6b0095cbfd181c..1051c3d96d37619e0e507cc845f144a45a9bb421 100644 --- a/filter/impl/tps/tps_limit_strategy.go +++ b/filter/tps_limit_strategy.go @@ -15,7 +15,7 @@ * limitations under the License. */ -package tps +package filter /* * please register your implementation by invoking SetTpsLimitStrategy diff --git a/filter/impl/tps/tps_limiter.go b/filter/tps_limiter.go similarity index 98% rename from filter/impl/tps/tps_limiter.go rename to filter/tps_limiter.go index 0622a957a8ba14fdebb52ff44ecf72da17703163..1d2b2341ac7d9b12f75d373909b0baa58bc7295f 100644 --- a/filter/impl/tps/tps_limiter.go +++ b/filter/tps_limiter.go @@ -15,7 +15,7 @@ * limitations under the License. */ -package tps +package filter import ( "github.com/apache/dubbo-go/common"