Class: Lhm::Throttler::Slave
- Inherits:
-
Object
- Object
- Lhm::Throttler::Slave
- Defined in:
- lib/lhm/throttler/slave_lag.rb
Constant Summary collapse
- SQL_SELECT_SLAVE_HOSTS =
"SELECT host FROM information_schema.processlist WHERE command LIKE 'Binlog Dump%'"
- SQL_SELECT_MAX_SLAVE_LAG =
'SHOW SLAVE STATUS'
Instance Attribute Summary collapse
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
-
#host ⇒ Object
readonly
Returns the value of attribute host.
Instance Method Summary collapse
-
#initialize(host, connection_config = nil) ⇒ Slave
constructor
A new instance of Slave.
- #lag ⇒ Object
- #slave_hosts ⇒ Object
Constructor Details
#initialize(host, connection_config = nil) ⇒ Slave
Returns a new instance of Slave.
94 95 96 97 98 |
# File 'lib/lhm/throttler/slave_lag.rb', line 94 def initialize(host, connection_config = nil) @host = host @connection_config = prepare_connection_config(connection_config) @connection = client(@connection_config) end |
Instance Attribute Details
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
92 93 94 |
# File 'lib/lhm/throttler/slave_lag.rb', line 92 def connection @connection end |
#host ⇒ Object (readonly)
Returns the value of attribute host.
92 93 94 |
# File 'lib/lhm/throttler/slave_lag.rb', line 92 def host @host end |
Instance Method Details
#lag ⇒ Object
104 105 106 |
# File 'lib/lhm/throttler/slave_lag.rb', line 104 def lag query_connection(SQL_SELECT_MAX_SLAVE_LAG, 'Seconds_Behind_Master').first.to_i end |
#slave_hosts ⇒ Object
100 101 102 |
# File 'lib/lhm/throttler/slave_lag.rb', line 100 def slave_hosts Throttler.format_hosts(query_connection(SQL_SELECT_SLAVE_HOSTS, 'host')) end |