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.
17 18 19 20 21 22 |
# File 'lib/speed_limiter/throttle.rb', line 17 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.
23 24 25 |
# File 'lib/speed_limiter/throttle.rb', line 23 def block @block end |
#config ⇒ Object (readonly)
Returns the value of attribute config.
23 24 25 |
# File 'lib/speed_limiter/throttle.rb', line 23 def config @config end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
23 24 25 |
# File 'lib/speed_limiter/throttle.rb', line 23 def params @params end |
Instance Method Details
#call {|state| ... } ⇒ any
Returns block return value.
30 31 32 33 34 35 36 |
# File 'lib/speed_limiter/throttle.rb', line 30 def call(&block) if use_retryable? Retryable.retryable(**) { run_block(&block) } else run_block(&block) end end |