Class: Mysqlknife::Mysql::Replica
- Inherits:
-
Object
- Object
- Mysqlknife::Mysql::Replica
- Defined in:
- lib/mysqlknife/mysql/replica.rb
Instance Attribute Summary collapse
-
#behind ⇒ Object
writeonly
Sets the attribute behind.
Instance Method Summary collapse
- #check_status_negative(behind) ⇒ Object
-
#initialize ⇒ Replica
constructor
A new instance of Replica.
- #rds? ⇒ Boolean
- #skip ⇒ Object
- #slave_status ⇒ Object
Constructor Details
#initialize ⇒ Replica
Returns a new instance of Replica.
8 9 10 11 12 |
# File 'lib/mysqlknife/mysql/replica.rb', line 8 def initialize @mysql = MySQL.new @mysql_cmd = Mysql::Command.new @mysql_sql = Mysql::SQL.new end |
Instance Attribute Details
#behind=(value) ⇒ Object (writeonly)
Sets the attribute behind
6 7 8 |
# File 'lib/mysqlknife/mysql/replica.rb', line 6 def behind=(value) @behind = value end |
Instance Method Details
#check_status_negative(behind) ⇒ Object
14 15 16 |
# File 'lib/mysqlknife/mysql/replica.rb', line 14 def check_status_negative(behind) @behind < 0 && behind < 0 && behind <= @behind && behind != 0 end |
#rds? ⇒ Boolean
18 19 20 |
# File 'lib/mysqlknife/mysql/replica.rb', line 18 def rds? ! @mysql.execute(@mysql_sql.show_procedure('rds_skip_repl_error')).first end |
#skip ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/mysqlknife/mysql/replica.rb', line 26 def skip status = slave_status if check_status_negative(status['Seconds_Behind_Master']) Mysqlknife::Log.new.skip_repl_error(status) if rds? @mysql.execute(@mysql_sql.rds_skip_repl_error) else @mysql.execute(@mysql_sql.mysql_skip_repl_error) end end end |
#slave_status ⇒ Object
22 23 24 |
# File 'lib/mysqlknife/mysql/replica.rb', line 22 def slave_status @mysql.execute(@mysql_sql.slave_status).first end |