Module: Lhm::Throttler

Included in:
Lhm
Defined in:
lib/lhm/throttler.rb,
lib/lhm/throttler/time.rb,
lib/lhm/throttler/slave_lag.rb,
lib/lhm/throttler/replica_lag.rb,
lib/lhm/throttler/threads_running.rb

Defined Under Namespace

Classes: Factory, LegacyTime, Replica, ReplicaLag, SlaveLag, ThreadsRunning, Time

Constant Summary collapse

CLASSES =
{
  :time_throttler => Throttler::Time,
  :replica_lag_throttler => Throttler::ReplicaLag,
  :slave_lag_throttler => Throttler::SlaveLag,
  :threads_running_throttler => Throttler::ThreadsRunning
}

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.format_hosts(hosts) ⇒ Object



4
5
6
7
8
9
10
11
12
# File 'lib/lhm/throttler/replica_lag.rb', line 4

def self.format_hosts(hosts)
  formatted_hosts = []
  hosts.each do |host|
    if host && !host.match(/localhost/) && !host.match(/127.0.0.1/)
      formatted_hosts << host.partition(':')[0]
    end
  end
  formatted_hosts
end

Instance Method Details

#setup_throttler(type, options = {}) ⇒ Object



19
20
21
# File 'lib/lhm/throttler.rb', line 19

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

#throttlerObject



15
16
17
# File 'lib/lhm/throttler.rb', line 15

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