Class: Rack::Throttle::Daily
- Inherits:
-
TimeWindow
- Object
- Limiter
- TimeWindow
- Rack::Throttle::Daily
- Defined in:
- lib/rack/throttle/limiters/daily.rb
Overview
This rate limiter strategy throttles the application by defining a maximum number of allowed HTTP requests per day (by default, 86,400 requests per 24 hours, which works out to an average of 1 request per second).
Note that this strategy doesn’t use a sliding time window, but rather tracks requests per calendar day. This means that the throttling counter is reset at midnight (according to the server’s local timezone) every night.
Instance Attribute Summary
Attributes inherited from Limiter
Instance Method Summary collapse
-
#initialize(app, options = {}) ⇒ Daily
constructor
A new instance of Daily.
- #max_per_day ⇒ Object (also: #max_per_window)
Methods inherited from TimeWindow
Methods inherited from Limiter
#allowed?, #blacklisted?, #call, #restricted_url?, #whitelisted?
Constructor Details
#initialize(app, options = {}) ⇒ Daily
Returns a new instance of Daily.
24 25 26 |
# File 'lib/rack/throttle/limiters/daily.rb', line 24 def initialize(app, = {}) super end |
Instance Method Details
#max_per_day ⇒ Object Also known as: max_per_window
29 30 31 |
# File 'lib/rack/throttle/limiters/daily.rb', line 29 def max_per_day @max_per_hour ||= [:max_per_day] || [:max] || 86_400 end |