Class: Aikido::Zen::RateLimiter::Result
- Inherits:
-
Object
- Object
- Aikido::Zen::RateLimiter::Result
- Defined in:
- lib/aikido/zen/rate_limiter/result.rb
Overview
Holds the stats after checking if a request should be rate limited, which will be added to the Rack env.
Instance Attribute Summary collapse
-
#current_requests ⇒ Integer
readonly
Number of requests for the client in the current window.
-
#discriminator ⇒ String
readonly
The output of the configured discriminator block, used to uniquely identify a client (e.g. the remote IP).
-
#max_requests ⇒ Integer
readonly
Configured max number of requests per client.
-
#time_remaining ⇒ Integer
readonly
Number of seconds remaining until the window resets.
Instance Method Summary collapse
-
#initialize(throttled:, discriminator:, current_requests:, max_requests:, time_remaining:) ⇒ Result
constructor
A new instance of Result.
-
#throttled? ⇒ Boolean
Whether the current request was throttled or not.
Constructor Details
#initialize(throttled:, discriminator:, current_requests:, max_requests:, time_remaining:) ⇒ Result
Returns a new instance of Result.
18 19 20 21 22 23 24 |
# File 'lib/aikido/zen/rate_limiter/result.rb', line 18 def initialize(throttled:, discriminator:, current_requests:, max_requests:, time_remaining:) @throttled = throttled @discriminator = discriminator @current_requests = current_requests @max_requests = max_requests @time_remaining = time_remaining end |
Instance Attribute Details
#current_requests ⇒ Integer (readonly)
Returns number of requests for the client in the current window.
10 11 12 |
# File 'lib/aikido/zen/rate_limiter/result.rb', line 10 def current_requests @current_requests end |
#discriminator ⇒ String (readonly)
Returns the output of the configured discriminator block, used to uniquely identify a client (e.g. the remote IP).
7 8 9 |
# File 'lib/aikido/zen/rate_limiter/result.rb', line 7 def discriminator @discriminator end |
#max_requests ⇒ Integer (readonly)
Returns configured max number of requests per client.
13 14 15 |
# File 'lib/aikido/zen/rate_limiter/result.rb', line 13 def max_requests @max_requests end |
#time_remaining ⇒ Integer (readonly)
Returns number of seconds remaining until the window resets.
16 17 18 |
# File 'lib/aikido/zen/rate_limiter/result.rb', line 16 def time_remaining @time_remaining end |
Instance Method Details
#throttled? ⇒ Boolean
Returns whether the current request was throttled or not.
27 28 29 |
# File 'lib/aikido/zen/rate_limiter/result.rb', line 27 def throttled? @throttled end |