Class: Karafka::Cli::Topics

Inherits:
Base
  • Object
show all
Includes:
Helpers::Colorize
Defined in:
lib/karafka/cli/topics.rb,
lib/karafka/cli/topics/base.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, 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 = 'missing') ⇒ Object

Parameters:

  • action (String) (defaults to: 'missing')

    action we want to take



33
34
35
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
# File 'lib/karafka/cli/topics.rb', line 33

def call(action = 'missing')
  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
            else
              raise ::ArgumentError, "Invalid topics action: #{action}"
            end

  changes = command.new.call

  return unless detailed_exit_code

  changes ? exit(CHANGES_EXIT_CODE) : exit(NO_CHANGES_EXIT_CODE)
end