Class: CMDx::RateLimit::Admission

Inherits:
Data
  • Object
show all
Defined in:
lib/cmdx/rate_limit.rb

Overview

Limiter decision for one admission attempt.

Built-in limiters set count for :fixed_window and level for :leaky_bucket; custom strategies may populate either or both. Omitted fields are stripped from telemetry and result metadata via compact.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#admitted ⇒ Boolean (readonly)

whether the run may proceed

Returns:

  • (Boolean) —

    the current value of admitted



24
25
26
# File 'lib/cmdx/rate_limit.rb', line 24

def admitted
  @admitted
end

#count ⇒ Integer? (readonly)

counter after increment (:fixed_window)

Returns:

  • (Integer, nil) —

    the current value of count



24
25
26
# File 'lib/cmdx/rate_limit.rb', line 24

def count
  @count
end

#level ⇒ Float? (readonly)

bucket fill after leak math (:leaky_bucket)

Returns:

  • (Float, nil) —

    the current value of level



24
25
26
# File 'lib/cmdx/rate_limit.rb', line 24

def level
  @level
end

#limiter ⇒ Symbol, #call (readonly)

strategy name or callable identity

Returns:

  • (Symbol, #call) —

    the current value of limiter



24
25
26
# File 'lib/cmdx/rate_limit.rb', line 24

def limiter
  @limiter
end

#retry_after ⇒ Integer? (readonly)

seconds until retry might succeed

Returns:

  • (Integer, nil) —

    the current value of retry_after



24
25
26
# File 'lib/cmdx/rate_limit.rb', line 24

def retry_after
  @retry_after
end

Instance Method Details

#admitted? ⇒ Boolean

Returns same as admitted.

Returns:

  • (Boolean) —

    same as admitted



26
27
28
# File 'lib/cmdx/rate_limit.rb', line 26

def admitted?
  admitted
end