Class: SpeedLimiter::Throttle
- Inherits:
-
Object
- Object
- SpeedLimiter::Throttle
- Extended by:
- Forwardable
- Defined in:
- lib/speed_limiter/throttle.rb
Overview
with actual throttle limits
Instance Attribute Summary collapse
-
#block ⇒ Object
readonly
Returns the value of attribute block.
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
Instance Method Summary collapse
-
#call {|state| ... } ⇒ any
Block return value.
-
#initialize(key, config:, **params) ⇒ Throttle
constructor
A new instance of Throttle.
Constructor Details
#initialize(key, config:, **params) ⇒ Throttle
Returns a new instance of Throttle.
21 22 23 24 25 26 |
# File 'lib/speed_limiter/throttle.rb', line 21 def initialize(key, config:, **params) params[:key] = key.to_s @config = config @params = ThrottleParams.new(config: config, **params) end |
Instance Attribute Details
#block ⇒ Object (readonly)
Returns the value of attribute block.
27 28 29 |
# File 'lib/speed_limiter/throttle.rb', line 27 def block @block end |
#config ⇒ Object (readonly)
Returns the value of attribute config.
27 28 29 |
# File 'lib/speed_limiter/throttle.rb', line 27 def config @config end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
27 28 29 |
# File 'lib/speed_limiter/throttle.rb', line 27 def params @params end |
Instance Method Details
#call {|state| ... } ⇒ any
Returns block return value.
38 39 40 41 42 43 44 |
# File 'lib/speed_limiter/throttle.rb', line 38 def call(&block) if use_retryable? Retryable.retryable(**) { run_block(&block) } else run_block(&block) end end |