Class: LHC::Throttle
- Inherits:
-
Interceptor
- Object
- Interceptor
- LHC::Throttle
- Defined in:
- lib/lhc/interceptors/throttle.rb
Defined Under Namespace
Classes: OutOfQuota
Class Attribute Summary collapse
-
.track ⇒ Object
Returns the value of attribute track.
Attributes inherited from Interceptor
Instance Method Summary collapse
Methods inherited from Interceptor
#after_request, #all_interceptor_classes, #before_raw_request, #before_response, dup, #initialize, #response
Constructor Details
This class inherits a constructor from LHC::Interceptor
Class Attribute Details
.track ⇒ Object
Returns the value of attribute track.
10 11 12 |
# File 'lib/lhc/interceptors/throttle.rb', line 10 def track @track end |
Instance Method Details
#after_response ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/lhc/interceptors/throttle.rb', line 23 def after_response = response.request..dig(:throttle) return unless throttle?() self.class.track ||= {} self.class.track[.dig(:provider)] = { limit: limit(options: [:limit], response: response), remaining: remaining(options: [:remaining], response: response), expires: expires(options: [:expires], response: response) } end |
#before_request ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/lhc/interceptors/throttle.rb', line 13 def before_request = request..dig(:throttle) return unless = .dig(:break) return unless break_when_quota_reached! if .match?('%') end |