Sha256: 12410d1269eb735a990a2383893d58ab63572d98aa2a4323e6a6b735c0eb72b6

Contents?: true

Size: 657 Bytes

Versions: 4

Compression:

Stored size: 657 Bytes

Contents

module Prop
  class RateLimited < StandardError
    attr_accessor :handle, :cache_key, :retry_after, :description

    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
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
prop-1.0.2 lib/prop/rate_limited.rb
prop-1.0.1 lib/prop/rate_limited.rb
prop-1.0.0 lib/prop/rate_limited.rb
prop-0.7.8 lib/prop/rate_limited.rb