Class: Karafka::Cli::Topics

Inherits:
Base
  • Object
show all
Includes:
Helpers::Colorize, Pro::Cli::Topics::Extension
Defined in:
lib/karafka/cli/topics.rb,
lib/karafka/cli/topics/base.rb,
lib/karafka/cli/topics/help.rb,
lib/karafka/cli/topics/plan.rb,
lib/karafka/cli/topics/align.rb,
lib/karafka/cli/topics/reset.rb,
lib/karafka/cli/topics/create.rb,
lib/karafka/cli/topics/delete.rb,
lib/karafka/cli/topics/migrate.rb,
lib/karafka/cli/topics/repartition.rb

Overview

CLI actions related to Kafka cluster topics management

Defined Under Namespace

Classes: Align, Base, Create, Delete, Help, Migrate, Plan, Repartition, Reset

Instance Attribute Summary

Attributes inherited from Base

#options

Instance Method Summary collapse

Methods included from Helpers::Colorize

#green, #grey, #red, #yellow

Methods inherited from Base

aliases, commands, desc, #initialize, load, name, names, option, parse_options

Constructor Details

This class inherits a constructor from Karafka::Cli::Base

Instance Method Details

#call(action = "help") ⇒ Object

Parameters:

  • action (String) (defaults to: "help")

    action we want to take



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/karafka/cli/topics.rb', line 36

def call(action = "help")
  detailed_exit_code = options.fetch(:detailed_exitcode, false)

  command = case action
  when "create"
    Topics::Create
  when "delete"
    Topics::Delete
  when "reset"
    Topics::Reset
  when "repartition"
    Topics::Repartition
  when "migrate"
    Topics::Migrate
  when "align"
    Topics::Align
  when "plan"
    Topics::Plan
  when "help"
    Topics::Help
  else
    raise Errors::UnrecognizedCommandError, "Unrecognized topics action: #{action}"
  end

  changes = command.new.call

  return unless detailed_exit_code

  changes ? exit(CHANGES_EXIT_CODE) : exit(NO_CHANGES_EXIT_CODE)
rescue Errors::CommandValidationError
  exit(ERROR_EXIT_CODE)
end