class GitLab::Exporter::CLI::DatabaseRowCounts
Database
row counts query runner.
This will take the database connection and print the result to STDOUT
Constants
- COMMAND_NAME
Public Class Methods
new(args)
click to toggle source
# File lib/gitlab_exporter/cli.rb, line 126 def initialize(args) @options = options(args) @options.parse! @target = args.shift || STDOUT @target = File.open(@target, "a") if @target.is_a?(String) end
Public Instance Methods
help()
click to toggle source
# File lib/gitlab_exporter/cli.rb, line 143 def help @options.help end
options(args)
click to toggle source
# File lib/gitlab_exporter/cli.rb, line 134 def options(args) args.options do |opts| opts.banner = "Usage: #{EXECUTABLE_NAME} #{COMMAND_NAME} [options]" opts.on("--db-conn=\"dbname=test port=5432\"", "Database connection string") do |val| @db_connection_string = val end end end
run()
click to toggle source
# File lib/gitlab_exporter/cli.rb, line 147 def run validate! ::GitLab::Exporter::Database::RowCountProber.new(connection_string: @db_connection_string) .probe_db .write_to(@target) end
Private Instance Methods
validate!()
click to toggle source
# File lib/gitlab_exporter/cli.rb, line 157 def validate! fail InvalidCLICommand.new(help) unless @db_connection_string end