class Samidare::EmbulkClient

Public Instance Methods

generate_config(bq_config) click to toggle source
# File lib/samidare.rb, line 8
def generate_config(bq_config)
  Samidare::EmbulkUtility::ConfigGenerator.new.generate_config(database_configs, bq_config)
end
run(bq_config, target_table_names = [], retry_max = 0) click to toggle source
# File lib/samidare.rb, line 12
def run(bq_config, target_table_names = [], retry_max = 0)
  error_tables = run_and_retry(bq_config, target_table_names, retry_max, 0)
  # return batch status(true: all tables success)
  error_tables.size == 0
end

Private Instance Methods

database_configs() click to toggle source
# File lib/samidare.rb, line 34
def database_configs
  @database_configs ||= YAML.load_file('database.yml')
end
run_and_retry(bq_config, target_table_names = [], retry_max, retry_count) click to toggle source
# File lib/samidare.rb, line 19
def run_and_retry(bq_config, target_table_names = [], retry_max, retry_count)
  error_tables = Samidare::Embulk.new.run(
    database_configs,
    table_configs,
    bq_config,
    target_table_names)
  if error_tables.size > 0 && retry_count < retry_max
    puts "------------------------------------"
    puts "retry start -> #{retry_count + 1} time"
    puts "------------------------------------"
    error_tables = run_and_retry(bq_config, error_tables, retry_max, retry_count + 1)
  end
  error_tables
end
table_configs() click to toggle source
# File lib/samidare.rb, line 38
def table_configs
  @table_configs ||= Samidare::MySQL::TableConfig.generate_table_configs
end