class MysqlSlaver::Slaver
Attributes
data_copier[R]
master_changer[R]
no_copy[R]
status_fetcher[R]
tables[R]
Public Class Methods
new(params)
click to toggle source
# File lib/mysql_slaver/slaver.rb, line 13 def initialize(params) mysql_root_password = params.fetch(:mysql_root_password, '') port = params.fetch(:port, 3306) ssh_port = params.fetch(:ssh_port, 22) socket_file = params.fetch(:socket_file, nil) tables = params.fetch(:tables, nil) @no_copy = params.fetch(:no_copy, false) dry_run = params.fetch(:dry_run, false) executor = Executor.new(ssh_port: params[:ssh_port], dry_run: dry_run) @status_fetcher = params.fetch(:status_fetcher) { StatusFetcher.new( master_host: params.fetch(:master_host), mysql_root_password: mysql_root_password, socket_file: socket_file, ssh_port: ssh_port, executor: executor ) } @data_copier = params.fetch(:data_copier) { DbCopier.new( master_host: params.fetch(:master_host), mysql_root_password: mysql_root_password, database: params.fetch(:database), port: port, socket_file: socket_file, tables: tables, ssh_port: ssh_port, executor: executor ) } @master_changer = params.fetch(:master_changer) { MasterChanger.new( master_host: params.fetch(:master_host), mysql_root_password: mysql_root_password, replication_user: params.fetch(:replication_user), replication_password: params.fetch(:replication_password), port: port, socket_file: socket_file, executor: executor ) } end
Public Instance Methods
enslave!()
click to toggle source
# File lib/mysql_slaver/slaver.rb, line 60 def enslave! master_status = status_fetcher.status data_copier.copy! unless no_copy master_changer.change!(master_status) rescue Exception => e log e.message end