Class: Labkit::RateLimit::Result
- Inherits:
-
Data
- Object
- Data
- Labkit::RateLimit::Result
- Defined in:
- lib/labkit/rate_limit/result.rb
Overview
Result is the return value of Limiter#check. matched? - true if a rule’s match conditions were satisfied exceeded? - true if the matched rule’s counter exceeded its limit action - the outcome: what the caller should do
:block = rule matched, exceeded, rule configured to block
:log = rule matched, exceeded, rule configured to log only
:allow = rule matched but count within limit, or
no rule matched, or error (fail-open)
The rule's configured action is available via rule.action
rule - the matched Rule object (nil when matched? is false) error? - true if Redis was unavailable; result fails open (exceeded? is false) resolved_limit - the resolved limit value as Integer (nil when matched? is false or error) resolved_period - the resolved period value as Integer (nil when matched? is false or error)
Instance Attribute Summary collapse
-
#action ⇒ Object
readonly
Returns the value of attribute action.
-
#error ⇒ Object
readonly
Returns the value of attribute error.
-
#exceeded ⇒ Object
readonly
Returns the value of attribute exceeded.
-
#matched ⇒ Object
readonly
Returns the value of attribute matched.
-
#resolved_limit ⇒ Object
readonly
Returns the value of attribute resolved_limit.
-
#resolved_period ⇒ Object
readonly
Returns the value of attribute resolved_period.
-
#rule ⇒ Object
readonly
Returns the value of attribute rule.
Instance Method Summary collapse
- #error? ⇒ Boolean
- #exceeded? ⇒ Boolean
-
#initialize(matched:, action:, exceeded: false, rule: nil, error: false, resolved_limit: nil, resolved_period: nil) ⇒ Result
constructor
A new instance of Result.
- #matched? ⇒ Boolean
Constructor Details
#initialize(matched:, action:, exceeded: false, rule: nil, error: false, resolved_limit: nil, resolved_period: nil) ⇒ Result
Returns a new instance of Result.
19 20 21 22 23 |
# File 'lib/labkit/rate_limit/result.rb', line 19 def initialize( matched:, action:, exceeded: false, rule: nil, error: false, resolved_limit: nil, resolved_period: nil) super end |
Instance Attribute Details
#action ⇒ Object (readonly)
Returns the value of attribute action
18 19 20 |
# File 'lib/labkit/rate_limit/result.rb', line 18 def action @action end |
#error ⇒ Object (readonly)
Returns the value of attribute error
18 19 20 |
# File 'lib/labkit/rate_limit/result.rb', line 18 def error @error end |
#exceeded ⇒ Object (readonly)
Returns the value of attribute exceeded
18 19 20 |
# File 'lib/labkit/rate_limit/result.rb', line 18 def exceeded @exceeded end |
#matched ⇒ Object (readonly)
Returns the value of attribute matched
18 19 20 |
# File 'lib/labkit/rate_limit/result.rb', line 18 def matched @matched end |
#resolved_limit ⇒ Object (readonly)
Returns the value of attribute resolved_limit
18 19 20 |
# File 'lib/labkit/rate_limit/result.rb', line 18 def resolved_limit @resolved_limit end |
#resolved_period ⇒ Object (readonly)
Returns the value of attribute resolved_period
18 19 20 |
# File 'lib/labkit/rate_limit/result.rb', line 18 def resolved_period @resolved_period end |
#rule ⇒ Object (readonly)
Returns the value of attribute rule
18 19 20 |
# File 'lib/labkit/rate_limit/result.rb', line 18 def rule @rule end |
Instance Method Details
#error? ⇒ Boolean
33 34 35 |
# File 'lib/labkit/rate_limit/result.rb', line 33 def error? error end |
#exceeded? ⇒ Boolean
29 30 31 |
# File 'lib/labkit/rate_limit/result.rb', line 29 def exceeded? exceeded end |
#matched? ⇒ Boolean
25 26 27 |
# File 'lib/labkit/rate_limit/result.rb', line 25 def matched? matched end |