Module: RateLimit::Throttler

Included in:
Worker
Defined in:
lib/rate_limit/throttler.rb

Instance Method Summary collapse

Instance Method Details

#throttleObject



5
6
7
8
9
10
11
12
13
14
# File 'lib/rate_limit/throttler.rb', line 5

def throttle
  return failure! if reloaded_limit_exceeded?

  yield if block_given?

  success!(skip_increment_cache: only_failures)
rescue StandardError => e
  success! unless e.is_a?(Errors::LimitExceededError)
  raise e
end