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

SCB-143 Add new rate limiter #235

Merged
merged 4 commits into from
Dec 29, 2017
Merged

SCB-143 Add new rate limiter #235

merged 4 commits into from
Dec 29, 2017

Conversation

asifdxtreme
Copy link
Member

Follow this checklist to help us incorporate your contribution quickly and easily:

  • Make sure there is a JIRA issue filed for the change (usually before you start working on it). Trivial changes like typos do not require a JIRA issue. Your pull request should address just this issue, without pulling in other changes.
  • Each commit in the pull request should have a meaningful subject line and body.
  • Format the pull request title like [SCB-XXX] Fixes bug in ApproximateQuantiles, where you replace SCB-XXX with the appropriate JIRA issue.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Run mvn clean install to make sure basic checks pass. A more thorough check will be performed on your pull request automatically.
  • If this contribution is large, please file an Apache Individual Contributor License Agreement.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.5%) to 72.078% when pulling 2025d74 on asifdxtreme:master into dec81c0 on apache:master.

@codecov-io
Copy link

codecov-io commented Dec 28, 2017

Codecov Report

Merging #235 into master will increase coverage by 0.08%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #235      +/-   ##
==========================================
+ Coverage   68.72%   68.81%   +0.08%     
==========================================
  Files          17       17              
  Lines        3562     3559       -3     
==========================================
+ Hits         2448     2449       +1     
+ Misses        938      936       -2     
+ Partials      176      174       -2
Impacted Files Coverage Δ
server/service/instances.go 70.9% <0%> (+0.35%) ⬆️
server/service/service_dependency.go 75.86% <0%> (+0.86%) ⬆️

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 dec81c0...e908731. Read the comment docs.

limiter := &HttpLimiter{RequestLimit: max, TTL: ttl}
limiter.ContentType = "text/plain; charset=utf-8"
limiter.HttpMessage = "You have reached maximum request limit."
limiter.StatusCode = 429
Copy link
Member

Choose a reason for hiding this comment

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

Use http.StatusTooManyRequests replace the magic number

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed

w.Header().Add("X-Rate-Limit-Duration", limiter.TTL.String())
}

func checkExsistence(sliceString []string, needle string) bool {
Copy link
Member

Choose a reason for hiding this comment

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

checkExsistence -> checkExistence

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed

if httpError != nil {
w.Header().Add("Content-Type", this.tbLimiter.MessageContentType)
w.Header().Add("Content-Type", this.httpLimiter.ContentType)
w.WriteHeader(httpError.StatusCode)
w.Write(util.StringToBytesWithNoCopy(httpError.Message))
util.Logger().Warn("Reached maximum request limit!", nil)
Copy link
Member

Choose a reason for hiding this comment

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

please log print the limit remote ip and request URI

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed

@coveralls
Copy link

Coverage Status

Coverage increased (+0.04%) to 72.574% when pulling e908731 on asifdxtreme:master into dec81c0 on apache:master.

@asifdxtreme
Copy link
Member Author

@little-cui Thanks for reviewing, I have fixed the code based on your comments, kindle review...

@little-cui little-cui merged commit 349d4b2 into apache:master Dec 29, 2017
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.

None yet

4 participants