Class: GammaReplication::Command::BaseReplication

Inherits:
Base
  • Object
show all
Defined in:
lib/gamma_replication/command/base_replication.rb

Direct Known Subclasses

Dryrun, Start

Instance Method Summary collapse

Methods inherited from Base

#gamma_tables, #output_setting_warning

Constructor Details

#initialize(opts) ⇒ BaseReplication



6
7
8
9
10
11
12
13
14
# File 'lib/gamma_replication/command/base_replication.rb', line 6

def initialize(opts)
  super()
  setup_database(opts)
  setup_parser(opts)
  setup_maxwell(opts)
  initialize_stats
  @enable_stats = opts[:enable_stats].nil? ? true : opts[:enable_stats]
  @stats_interval = (opts[:stats_interval] || 3 * 60 * 60).to_i # Default: 3 hours in seconds
end

Instance Method Details

#executeObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/gamma_replication/command/base_replication.rb', line 16

def execute
  tables = @data_parser.gamma_tables
  output_setting_warning(tables)

  @table_settings = tables.each_with_object({}) do |table, hash|
    hash[table.table_name] = table
  end
  before_start if respond_to?(:before_start)

  setup_stats_reporter if @enable_stats

  @maxwell_client.start do |data|
    process_maxwell_data(data)
  end
end