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.



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

def initialize(options)
  handle    = options.fetch(:handle)
  cache_key = options.fetch(:cache_key)
  interval  = options.fetch(:interval).to_i
  threshold = options.fetch(:threshold).to_i

  super("#{handle} threshold of #{threshold} tries per #{interval}s exceeded for key '#{options[:key].inspect}', hash #{cache_key}")

  self.description = options[:description]
  self.handle      = handle
  self.cache_key   = cache_key
  self.retry_after = interval - Time.now.to_i % interval
end

Instance Attribute Details

#cache_keyObject

Returns the value of attribute cache_key.



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

def cache_key
  @cache_key
end

#descriptionObject

Returns the value of attribute description.



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

def description
  @description
end

#handleObject

Returns the value of attribute handle.



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

def handle
  @handle
end

#retry_afterObject

Returns the value of attribute retry_after.



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

def retry_after
  @retry_after
end