class GitLab::Exporter::CLI::SidekiqRunner

Sidekiq runner.

It will take a Redis connection URL and print results to STDOUT

Constants

COMMAND_NAME

Public Class Methods

new(args) click to toggle source
# File lib/gitlab_exporter/cli.rb, line 251
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 268
def help
  @options.help
end
options(args) click to toggle source
# File lib/gitlab_exporter/cli.rb, line 259
def options(args)
  args.options do |opts|
    opts.banner = "Usage: #{EXECUTABLE_NAME} #{COMMAND_NAME} [options]"
    opts.on("--redis-url=\"redis://localhost:6379\"", "Redis URL") do |val|
      @redis_url = val
    end
  end
end
run() click to toggle source
# File lib/gitlab_exporter/cli.rb, line 272
def run
  validate!

  ::GitLab::Exporter::SidekiqProber.new(redis_url: @redis_url)
                                   .probe_stats
                                   .probe_queues
                                   .probe_jobs_limit
                                   .probe_workers
                                   .probe_retries
                                   .write_to(@target)
end

Private Instance Methods

validate!() click to toggle source
# File lib/gitlab_exporter/cli.rb, line 286
def validate!
  fail InvalidCLICommand.new(help) unless @redis_url
end