Class: Rare::Throttler
- Inherits:
-
Object
- Object
- Rare::Throttler
- Defined in:
- lib/rare/throttler.rb
Instance Method Summary collapse
-
#initialize ⇒ Throttler
constructor
A new instance of Throttler.
- #throttle(rpm:, key: 'default') ⇒ Object
Constructor Details
#initialize ⇒ Throttler
Returns a new instance of Throttler.
5 6 7 |
# File 'lib/rare/throttler.rb', line 5 def initialize @mutex = Mutex.new end |
Instance Method Details
#throttle(rpm:, key: 'default') ⇒ Object
9 10 11 12 13 |
# File 'lib/rare/throttler.rb', line 9 def throttle(rpm:, key: 'default') sleep sleep_interval until allowed?(seconds(rpm), key) yield if block_given? end |