Class: ExcessFlow::FixedWindowStrategy
- Defined in:
- lib/excess_flow/fixed_window_strategy.rb
Overview
ExcessFlow::FixedWindowStrategy
Definition of fixed window rate limiting strategy and it’s behaviour implementations. Fixed window allows only N requests for a given key to be done in a O time window where O start is defined at the time of first request. Window expiration starts with the first request for a given key. Once expired it will reset back to 0.
Instance Attribute Summary
Attributes inherited from Strategy
Instance Method Summary collapse
Methods inherited from Strategy
execute, #execute, #initialize
Constructor Details
This class inherits a constructor from ExcessFlow::Strategy
Instance Method Details
#within_rate_limit? ⇒ Boolean
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/excess_flow/fixed_window_strategy.rb', line 26 def within_rate_limit? ExcessFlow::GlobalMutex.locked(lock_key: configuration.lock_key) do if current_requests < configuration.limit bump_counter start_expiration_window true else false end end end |