Sha256: 4daf74abaac7e9e332ff6dcd047486b13a65368ed53084e92108edc09c610903

Contents?: true

Size: 622 Bytes

Versions: 6

Compression:

Stored size: 622 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
      strategy  = options.fetch(:strategy)

      super(strategy.threshold_reached(options))

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

    def config
      Prop.configurations[@handle]
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
prop-2.0.4 lib/prop/rate_limited.rb
prop-2.0.3 lib/prop/rate_limited.rb
prop-2.0.2 lib/prop/rate_limited.rb
prop-2.0.1 lib/prop/rate_limited.rb
prop-2.0.0 lib/prop/rate_limited.rb
prop-1.2.0 lib/prop/rate_limited.rb