Class: GitLab::Exporter::CLI::DatabaseRowCounts
- Inherits:
-
Object
- Object
- GitLab::Exporter::CLI::DatabaseRowCounts
- Defined in:
- lib/gitlab_exporter/cli.rb
Overview
Database row counts query runner.
This will take the database connection and print the result to STDOUT
Constant Summary collapse
- COMMAND_NAME =
"row-counts".freeze
Instance Method Summary collapse
- #help ⇒ Object
-
#initialize(args) ⇒ DatabaseRowCounts
constructor
A new instance of DatabaseRowCounts.
- #options(args) ⇒ Object
- #run ⇒ Object
Constructor Details
#initialize(args) ⇒ DatabaseRowCounts
Returns a new instance of DatabaseRowCounts.
142 143 144 145 146 147 148 |
# File 'lib/gitlab_exporter/cli.rb', line 142 def initialize(args) @options = (args) @options.parse! @target = args.shift || STDOUT @target = File.open(@target, "a") if @target.is_a?(String) end |
Instance Method Details
#help ⇒ Object
159 160 161 |
# File 'lib/gitlab_exporter/cli.rb', line 159 def help @options.help end |
#options(args) ⇒ Object
150 151 152 153 154 155 156 157 |
# File 'lib/gitlab_exporter/cli.rb', line 150 def (args) args. do |opts| opts. = "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 ⇒ Object
163 164 165 166 167 168 169 |
# File 'lib/gitlab_exporter/cli.rb', line 163 def run validate! ::GitLab::Exporter::Database::RowCountProber.new(connection_string: @db_connection_string) .probe_db .write_to(@target) end |