Class: MysqlSlaver::StatusFetcher
- Inherits:
-
Object
- Object
- MysqlSlaver::StatusFetcher
- Includes:
- Logger, MysqlCommand
- Defined in:
- lib/mysql_slaver/status_fetcher.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.
-
#socket_file ⇒ Object
Returns the value of attribute socket_file.
Instance Method Summary collapse
-
#initialize(params) ⇒ StatusFetcher
constructor
A new instance of StatusFetcher.
- #status ⇒ Object
Methods included from MysqlCommand
#mysql_command, #mysql_credentials
Methods included from Logger
Constructor Details
#initialize(params) ⇒ StatusFetcher
Returns a new instance of StatusFetcher.
8 9 10 11 12 13 |
# File 'lib/mysql_slaver/status_fetcher.rb', line 8 def initialize(params) @master_host = params.fetch(:master_host) @socket_file = params.fetch(:socket_file, nil) @mysql_root_password = params.fetch(:mysql_root_password, '') @executor = params.fetch(:executor) { Executor.new(ssh_port: params[:ssh_port]) } end |
Instance Attribute Details
#executor ⇒ Object
Returns the value of attribute executor.
6 7 8 |
# File 'lib/mysql_slaver/status_fetcher.rb', line 6 def executor @executor end |
#master_host ⇒ Object
Returns the value of attribute master_host.
6 7 8 |
# File 'lib/mysql_slaver/status_fetcher.rb', line 6 def master_host @master_host end |
#mysql_root_password ⇒ Object
Returns the value of attribute mysql_root_password.
6 7 8 |
# File 'lib/mysql_slaver/status_fetcher.rb', line 6 def mysql_root_password @mysql_root_password end |
#socket_file ⇒ Object
Returns the value of attribute socket_file.
6 7 8 |
# File 'lib/mysql_slaver/status_fetcher.rb', line 6 def socket_file @socket_file end |
Instance Method Details
#status ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/mysql_slaver/status_fetcher.rb', line 15 def status params = {root_password: mysql_root_password, socket_file: socket_file} cmd = mysql_command("show master status\\G", params) if data = executor.execute(executor.ssh_command(cmd, master_host)) rtn = parse data log "MASTER STATUS - file: #{rtn[:file]}, position: #{rtn[:position]}" rtn else raise Exception.new("Failed to get master status") end end |