Exception: Prop::RateLimited

Inherits:
StandardError
  • Object
show all
Defined in:
lib/prop/rate_limited.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ RateLimited

Returns a new instance of RateLimited.



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/prop/rate_limited.rb', line 6

def initialize(options)
  self.handle    = options.fetch(:handle)
  self.cache_key = options.fetch(:cache_key)
  self.first_throttled = options.fetch(:first_throttled)
  self.description = options[:description]

  interval  = options.fetch(:interval).to_i
  self.retry_after = interval - Time.now.to_i % interval

  super(options.fetch(:strategy).threshold_reached(options))
end

Instance Attribute Details

#cache_keyObject

Returns the value of attribute cache_key.



4
5
6
# File 'lib/prop/rate_limited.rb', line 4

def cache_key
  @cache_key
end

#descriptionObject

Returns the value of attribute description.



4
5
6
# File 'lib/prop/rate_limited.rb', line 4

def description
  @description
end

#first_throttledObject

Returns the value of attribute first_throttled.



4
5
6
# File 'lib/prop/rate_limited.rb', line 4

def first_throttled
  @first_throttled
end

#handleObject

Returns the value of attribute handle.



4
5
6
# File 'lib/prop/rate_limited.rb', line 4

def handle
  @handle
end

#retry_afterObject

Returns the value of attribute retry_after.



4
5
6
# File 'lib/prop/rate_limited.rb', line 4

def retry_after
  @retry_after
end

Instance Method Details

#configObject



18
19
20
# File 'lib/prop/rate_limited.rb', line 18

def config
  Prop.configurations.fetch(@handle)
end