Commit 42c74b25 authored by Ash McKenzie's avatar Ash McKenzie

Allow ApplicationRateLimiter to be instantiated

parent e8d68b12
...@@ -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
Markdown is supported
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