Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
42c74b25
Commit
42c74b25
authored
Sep 28, 2021
by
Ash McKenzie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow ApplicationRateLimiter to be instantiated
parent
e8d68b12
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
0 deletions
+21
-0
lib/gitlab/application_rate_limiter.rb
lib/gitlab/application_rate_limiter.rb
+21
-0
No files found.
lib/gitlab/application_rate_limiter.rb
View file @
42c74b25
...
@@ -11,6 +11,23 @@ module Gitlab
...
@@ -11,6 +11,23 @@ module Gitlab
# redirect_to(edit_project_path(@project), status: :too_many_requests)
# redirect_to(edit_project_path(@project), status: :too_many_requests)
# end
# end
class
ApplicationRateLimiter
class
ApplicationRateLimiter
def
initialize
(
key
,
**
options
)
@key
=
key
@options
=
options
end
def
throttled?
self
.
class
.
throttled?
(
key
,
**
options
)
end
def
threshold_value
options
[
:threshold
]
||
self
.
class
.
threshold
(
key
)
end
def
interval_value
self
.
class
.
interval
(
key
)
end
class
<<
self
class
<<
self
# Application rate limits
# Application rate limits
#
#
...
@@ -154,5 +171,9 @@ module Gitlab
...
@@ -154,5 +171,9 @@ module Gitlab
scoped_user
.
username
.
downcase
.
in?
(
options
[
:users_allowlist
])
scoped_user
.
username
.
downcase
.
in?
(
options
[
:users_allowlist
])
end
end
end
end
private
attr_reader
:key
,
:options
end
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment