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 (a :limit rule over its limit, or one whose ban is still in force) 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



143
144
145
# File 'lib/labkit/rate_limit/result.rb', line 143

def exceeded
  @exceeded
end

#infoObject (readonly)

Returns the value of attribute info

Returns:

  • (Object)

    the current value of info



143
144
145
# File 'lib/labkit/rate_limit/result.rb', line 143

def info
  @info
end

#ruleObject (readonly)

Returns the value of attribute rule

Returns:

  • (Object)

    the current value of rule



143
144
145
# File 'lib/labkit/rate_limit/result.rb', line 143

def rule
  @rule
end

Instance Method Details

#<=>(other) ⇒ Object



154
155
156
# File 'lib/labkit/rate_limit/result.rb', line 154

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

#block?Boolean

Returns:

  • (Boolean)


150
151
152
# File 'lib/labkit/rate_limit/result.rb', line 150

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

#exceeded?Boolean

Returns:

  • (Boolean)


146
147
148
# File 'lib/labkit/rate_limit/result.rb', line 146

def exceeded?
  exceeded
end