Class: GitLab::Exporter::CLI::DatabaseTupleStats
- Inherits:
-
Object
- Object
- GitLab::Exporter::CLI::DatabaseTupleStats
- Defined in:
- lib/gitlab_exporter/cli.rb
Overview
Database tuple stats runner.
It will take a database connection string and print results to STDOUT
Constant Summary collapse
- COMMAND_NAME =
"db-tuple-stats".freeze
Instance Method Summary collapse
- #help ⇒ Object
-
#initialize(args) ⇒ DatabaseTupleStats
constructor
A new instance of DatabaseTupleStats.
- #options(args) ⇒ Object
- #run ⇒ Object
Constructor Details
#initialize(args) ⇒ DatabaseTupleStats
Returns a new instance of DatabaseTupleStats.
84 85 86 87 88 89 90 |
# File 'lib/gitlab_exporter/cli.rb', line 84 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
101 102 103 |
# File 'lib/gitlab_exporter/cli.rb', line 101 def help @options.help end |
#options(args) ⇒ Object
92 93 94 95 96 97 98 99 |
# File 'lib/gitlab_exporter/cli.rb', line 92 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
105 106 107 108 109 110 111 |
# File 'lib/gitlab_exporter/cli.rb', line 105 def run validate! ::GitLab::Exporter::Database::TuplesProber.new(connection_string: @db_connection_string) .probe_db .write_to(@target) end |