Class: Rack::Throttle::Second
- Inherits:
-
TimeWindow
- Object
- Limiter
- TimeWindow
- Rack::Throttle::Second
- Defined in:
- lib/rack/throttle/second.rb
Overview
This rate limiter strategy throttles the application by defining a maximum number of allowed HTTP requests per second (by default, 1 request per second.
Note that this strategy doesn't use a sliding time window, but rather tracks requests per distinct second. This means that the throttling counter is reset every second.
Instance Attribute Summary
Attributes inherited from Limiter
Instance Method Summary collapse
-
#initialize(app, options = {}) ⇒ Second
constructor
A new instance of Second.
- #max_per_second(request = nil) ⇒ Object (also: #max_per_window)
Methods inherited from TimeWindow
Methods inherited from Limiter
#allowed?, #blacklisted?, #call, #whitelisted?
Constructor Details
#initialize(app, options = {}) ⇒ Second
Returns a new instance of Second.
22 23 24 |
# File 'lib/rack/throttle/second.rb', line 22 def initialize(app, = {}) super end |
Instance Method Details
#max_per_second(request = nil) ⇒ Object Also known as: max_per_window
27 28 29 |
# File 'lib/rack/throttle/second.rb', line 27 def max_per_second(request = nil) @max_per_second ||= [:max_per_second] || [:max] || 1 end |