Sha256: e7c2663dd90887149f369402f2d7436bf07d32bd330de23d733c3ebfbeb6c553

Contents?: true

Size: 653 Bytes

Versions: 10

Compression:

Stored size: 653 Bytes

Contents

# frozen_string_literal: true
module Prop
  class RateLimited < StandardError
    attr_accessor :handle, :cache_key, :retry_after, :description, :first_throttled

    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

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

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
prop-2.6.1 lib/prop/rate_limited.rb
prop-2.6.0 lib/prop/rate_limited.rb
prop-2.5.0 lib/prop/rate_limited.rb
prop-2.4.0 lib/prop/rate_limited.rb
prop-2.3.0 lib/prop/rate_limited.rb
prop-2.2.5 lib/prop/rate_limited.rb
prop-2.2.4 lib/prop/rate_limited.rb
prop-2.2.2 lib/prop/rate_limited.rb
prop-2.2.1 lib/prop/rate_limited.rb
prop-2.2.0 lib/prop/rate_limited.rb