Sha256: 5f00c944a1a42203a50ef1c2e93e55c58ee91a7f7a1a804c493407f9a9d292a6

Contents?: true

Size: 933 Bytes

Versions: 16

Compression:

Stored size: 933 Bytes

Contents

require 'lhm/throttler/time'
require 'lhm/throttler/slave_lag'
require 'lhm/throttler/threads_running'

module Lhm
  module Throttler
    CLASSES = { :time_throttler => Throttler::Time,
                :slave_lag_throttler => Throttler::SlaveLag,
                :threads_running_throttler => Throttler::ThreadsRunning }

    def throttler
      @throttler ||= Throttler::Time.new
    end

    def setup_throttler(type, options = {})
      @throttler = Factory.create_throttler(type, options)
    end

    class Factory
      def self.create_throttler(type, options = {})
        case type
        when Lhm::Command
          type
        when Symbol
          CLASSES[type].new(options)
        when String
          CLASSES[type.to_sym].new(options)
        when Class
          type.new(options)
        else
          raise ArgumentError, 'type argument must be a Symbol, String or Class'
        end
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 2 rubygems

Version Path
lhm-teak-3.6.4 lib/lhm/throttler.rb
lhm-teak-3.6.3 lib/lhm/throttler.rb
lhm-teak-3.6.2 lib/lhm/throttler.rb
lhm-teak-3.6.1 lib/lhm/throttler.rb
lhm-teak-3.6.0 lib/lhm/throttler.rb
lhm-shopify-3.5.5 lib/lhm/throttler.rb
lhm-shopify-3.5.4 lib/lhm/throttler.rb
lhm-shopify-3.5.3 lib/lhm/throttler.rb
lhm-shopify-3.5.2 lib/lhm/throttler.rb
lhm-shopify-3.5.0 lib/lhm/throttler.rb
lhm-shopify-3.5.1 lib/lhm/throttler.rb
lhm-shopify-3.4.2 lib/lhm/throttler.rb
lhm-shopify-3.4.1 lib/lhm/throttler.rb
lhm-shopify-3.4.0 lib/lhm/throttler.rb
lhm-shopify-3.3.6 lib/lhm/throttler.rb
lhm-shopify-3.3.5 lib/lhm/throttler.rb