Class: MysqlSlaver::MasterChanger
- Inherits:
-
Object
- Object
- MysqlSlaver::MasterChanger
- Includes:
- MysqlCommand
- Defined in:
- lib/mysql_slaver/master_changer.rb
Instance Attribute Summary collapse
-
#executor ⇒ Object
Returns the value of attribute executor.
-
#master_host ⇒ Object
Returns the value of attribute master_host.
-
#mysql_root_password ⇒ Object
Returns the value of attribute mysql_root_password.
-
#port ⇒ Object
Returns the value of attribute port.
-
#replication_password ⇒ Object
Returns the value of attribute replication_password.
-
#replication_user ⇒ Object
Returns the value of attribute replication_user.
-
#socket_file ⇒ Object
Returns the value of attribute socket_file.
Instance Method Summary collapse
- #change!(status) ⇒ Object
-
#initialize(params) ⇒ MasterChanger
constructor
A new instance of MasterChanger.
Methods included from MysqlCommand
#mysql_command, #mysql_credentials
Constructor Details
#initialize(params) ⇒ MasterChanger
Returns a new instance of MasterChanger.
7 8 9 10 11 12 13 14 15 |
# File 'lib/mysql_slaver/master_changer.rb', line 7 def initialize(params) @master_host = params.fetch(:master_host) @port = params.fetch(:port) @socket_file = params.fetch(:socket_file, nil) @mysql_root_password = params.fetch(:mysql_root_password, '') @replication_user = params.fetch(:replication_user) @replication_password = params.fetch(:replication_password) @executor = params.fetch(:executor) { Executor.new } end |
Instance Attribute Details
#executor ⇒ Object
Returns the value of attribute executor.
5 6 7 |
# File 'lib/mysql_slaver/master_changer.rb', line 5 def executor @executor end |
#master_host ⇒ Object
Returns the value of attribute master_host.
5 6 7 |
# File 'lib/mysql_slaver/master_changer.rb', line 5 def master_host @master_host end |
#mysql_root_password ⇒ Object
Returns the value of attribute mysql_root_password.
5 6 7 |
# File 'lib/mysql_slaver/master_changer.rb', line 5 def mysql_root_password @mysql_root_password end |
#port ⇒ Object
Returns the value of attribute port.
5 6 7 |
# File 'lib/mysql_slaver/master_changer.rb', line 5 def port @port end |
#replication_password ⇒ Object
Returns the value of attribute replication_password.
5 6 7 |
# File 'lib/mysql_slaver/master_changer.rb', line 5 def replication_password @replication_password end |
#replication_user ⇒ Object
Returns the value of attribute replication_user.
5 6 7 |
# File 'lib/mysql_slaver/master_changer.rb', line 5 def replication_user @replication_user end |
#socket_file ⇒ Object
Returns the value of attribute socket_file.
5 6 7 |
# File 'lib/mysql_slaver/master_changer.rb', line 5 def socket_file @socket_file end |
Instance Method Details
#change!(status) ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/mysql_slaver/master_changer.rb', line 17 def change!(status) cmds = [ 'stop slave', change_master(status), 'start slave' ] cmd = mysql_command(cmds.join('; '), mysql_params) executor.execute cmd end |