Sha256: 744613df921614b5d6ce13fbba457d56086a72e34df9744f5e6bf28b7007bb23

Contents?: true

Size: 706 Bytes

Versions: 3

Compression:

Stored size: 706 Bytes

Contents

module Lhm
  module Throttler
    class Time
      include Command
      include BackoffReduction

      DEFAULT_TIMEOUT = 0.1
      DEFAULT_STRIDE = 2_000
      DEFAULT_BACKOFF_REDUCTION_FACTOR = 0.2 # 20%
      MIN_STRIDE_SIZE = 1

      attr_accessor :timeout_seconds
      attr_accessor :stride

      def initialize(options = {})
        @timeout_seconds = options[:delay] || DEFAULT_TIMEOUT
        @stride = options[:stride] || DEFAULT_STRIDE

        super
      end

      def execute
        sleep timeout_seconds
      end
    end

    class LegacyTime < Time
      def initialize(timeout, stride)
        @timeout_seconds = timeout / 1000.0
        @stride = stride
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
lhm-shopify-4.5.0 lib/lhm/throttler/time.rb
lhm-shopify-4.4.2 lib/lhm/throttler/time.rb
lhm-shopify-4.4.1 lib/lhm/throttler/time.rb