module MixedGauge::DatabaseTasks::TaskOrganizerForSingleClusterTask
Organize cluster config and handle error for invalid args, call single cluster task with each single connection config.
Public Instance Methods
create_all_databases(args)
click to toggle source
@param [Hash{Symbol => String}] args
# File lib/mixed_gauge/database_tasks.rb, line 100 def create_all_databases(args) exec_task_for_all_databases('create', args) end
drop_all_databases(args)
click to toggle source
@param [Hash{Symbol => String}] args
# File lib/mixed_gauge/database_tasks.rb, line 105 def drop_all_databases(args) exec_task_for_all_databases('drop', args) end
load_schema_all_databases(args)
click to toggle source
@param [Hash{Symbol => String}] args
# File lib/mixed_gauge/database_tasks.rb, line 110 def load_schema_all_databases(args) exec_task_for_all_databases('load_schema', args) end
Private Instance Methods
cluster_name_or_error(name, args)
click to toggle source
@param [String] name A task name @param [Hash{Symbol => String}] args @return [String]
# File lib/mixed_gauge/database_tasks.rb, line 129 def cluster_name_or_error(name, args) unless (cluster_name = args[:cluster_name]) $stderr.puts <<-MSG Missing cluster_name. Find cluster_name via `rake mixed_gauge:info` then call `rake "mixed_gauge:#{name}[$cluster_name]"`. MSG exit_with_error end cluster_name end
cluster_or_error(cluster_name)
click to toggle source
@param [String] cluster_name @return [MixedGauge::ClusterConfig]
# File lib/mixed_gauge/database_tasks.rb, line 141 def cluster_or_error(cluster_name) fetch_cluster_config(cluster_name.to_sym) rescue KeyError $stderr.puts %(cluster name "#{cluster_name}" not found.) exit_with_error end
exec_task_for_all_databases(task_name, args)
click to toggle source
@param [String] task_name @param [Hash{Symbol => String}] args
# File lib/mixed_gauge/database_tasks.rb, line 118 def exec_task_for_all_databases(task_name, args) cluster_name = cluster_name_or_error(task_name, args) cluster = cluster_or_error(cluster_name) cluster.connections.each do |connection_name| __send__(task_name, connection_name.to_s) end end