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

Ftr: TpsLimitSupport #237

Merged
merged 12 commits into from
Oct 23, 2019
Merged

Ftr: TpsLimitSupport #237

merged 12 commits into from
Oct 23, 2019

Conversation

flycash
Copy link
Member

@flycash flycash commented Oct 15, 2019

What this PR does:
Add TpsLimitFilter. The TpsLimitFilter is one of the default filters. However, if the tps.limiter is nil or the tps.limit.rate < 0, the TpsLimitFilter will do nothing.

  1. define the interface of TpsLimiter and the implementation supporting both service-level and method-level limitation was provided.
  2. define the interface of RejectExecutionHandler. The default implementation only log the invocation info;
  3. define the interface of TpsLimitStrategy. Fixed-window, thread-safe fixed-window, sliding-window were provided;

Which issue(s) this PR fixes:
Ftr: TPSLimitFilter Support

Fixes #220

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

Now user can use the TpsLimitFilter and custom their implementation by implements the interfaces RejectedExecutionHandler, TpsLimitStrategy, TpsLimiter

@codecov-io
Copy link

codecov-io commented Oct 15, 2019

Codecov Report

Merging #237 into develop will increase coverage by 0.03%.
The diff coverage is 77.52%.

Impacted file tree graph

@@            Coverage Diff             @@
##           develop    #237      +/-   ##
==========================================
+ Coverage    65.36%   65.4%   +0.03%     
==========================================
  Files           95     104       +9     
  Lines         6563    6744     +181     
==========================================
+ Hits          4290    4411     +121     
- Misses        1832    1891      +59     
- Partials       441     442       +1
Impacted Files Coverage Δ
config/method_config.go 50% <ø> (ø) ⬆️
...r/impl/tps/impl/rejected_execution_handler_mock.go 0% <0%> (ø)
filter/impl/access_log_filter.go 71.02% <0%> (ø) ⬆️
filter/impl/tps/impl/tps_limiter_mock.go 0% <0%> (ø)
...impl/tps/impl/tps_limit_sliding_window_strategy.go 100% <100%> (ø)
...pl/tps/impl/rejected_execution_handler_only_log.go 100% <100%> (ø)
.../impl/tps_limit_thread_safe_fix_window_strategy.go 100% <100%> (ø)
filter/impl/tps/impl/tps_limit_strategy_mock.go 100% <100%> (ø)
config/service_config.go 68.75% <100%> (+3.23%) ⬆️
...ter/impl/tps/impl/tps_limit_fix_window_strategy.go 100% <100%> (ø)
... and 19 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 02d8718...7c9bcec. Read the comment docs.

common/extension/tps_limit.go Outdated Show resolved Hide resolved
common/extension/tps_limit.go Outdated Show resolved Hide resolved
common/extension/tps_limit.go Outdated Show resolved Hide resolved
common/extension/tps_limit.go Outdated Show resolved Hide resolved
filter/rejected_execution_handler_mock.go Outdated Show resolved Hide resolved
config/service_config.go Show resolved Hide resolved
config/service_config.go Show resolved Hide resolved
filter/impl/tps_limit_fix_window_strategy_impl_test.go Outdated Show resolved Hide resolved
@fangyincheng
Copy link
Contributor

has you checked it again by your examples, when modified?

@flycash
Copy link
Member Author

flycash commented Oct 17, 2019

I've tested end to end.

@flycash
Copy link
Member Author

flycash commented Oct 17, 2019

done, and had tested it again.

common/extension/tps_limit.go Outdated Show resolved Hide resolved
config/service_config.go Show resolved Hide resolved
@aliiohs
Copy link
Member

aliiohs commented Oct 20, 2019

LGTM

Copy link
Contributor

@fangyincheng fangyincheng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@AlexStocks
Copy link
Contributor

LGTM

Copy link
Contributor

@hxmhlt hxmhlt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@hxmhlt hxmhlt merged commit 656b1d6 into apache:develop Oct 23, 2019
@iHuangYaoshi
Copy link

Did you have considered impl the limiter by channel?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants