Class: Labkit::RateLimit::Result::Evaluation

Inherits:
Data
  • Object
show all
Includes:
Comparable
Defined in:
lib/labkit/rate_limit/result.rb

Overview

The outcome of counting one matched rule. rule - the evaluated Rule exceeded - whether the post-increment count exceeded the resolved limit info - Result::Info with the per-window counters

Evaluations order by constraint: a blocking evaluation (:limit rule over its limit) ranks strictly first - it decides the request no matter what any other rule reports - then exceeded ones, then fewest remaining. remaining floors at 0, so an exceeded :log rule ties with one sitting exactly on its limit; ranking exceeded ahead keeps a breach from being hidden by a rule that merely reached its limit.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#exceededObject (readonly)

Returns the value of attribute exceeded

Returns:

  • (Object)

    the current value of exceeded



128
129
130
# File 'lib/labkit/rate_limit/result.rb', line 128

def exceeded
  @exceeded
end

#infoObject (readonly)

Returns the value of attribute info

Returns:

  • (Object)

    the current value of info



128
129
130
# File 'lib/labkit/rate_limit/result.rb', line 128

def info
  @info
end

#ruleObject (readonly)

Returns the value of attribute rule

Returns:

  • (Object)

    the current value of rule



128
129
130
# File 'lib/labkit/rate_limit/result.rb', line 128

def rule
  @rule
end

Instance Method Details

#<=>(other) ⇒ Object



139
140
141
# File 'lib/labkit/rate_limit/result.rb', line 139

def <=>(other)
  constraint_rank <=> other.constraint_rank
end

#block?Boolean

Returns:

  • (Boolean)


135
136
137
# File 'lib/labkit/rate_limit/result.rb', line 135

def block?
  exceeded? && rule.action == :limit
end

#exceeded?Boolean

Returns:

  • (Boolean)


131
132
133
# File 'lib/labkit/rate_limit/result.rb', line 131

def exceeded?
  exceeded
end