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.
100 101 102 103 104 105 106 |
# File 'lib/gitlab_exporter/cli.rb', line 100 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
117 118 119 |
# File 'lib/gitlab_exporter/cli.rb', line 117 def help @options.help end |
#options(args) ⇒ Object
108 109 110 111 112 113 114 115 |
# File 'lib/gitlab_exporter/cli.rb', line 108 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
121 122 123 124 125 126 127 |
# File 'lib/gitlab_exporter/cli.rb', line 121 def run validate! ::GitLab::Exporter::Database::TuplesProber.new(connection_string: @db_connection_string) .probe_db .write_to(@target) end |