Class: Karafka::Cli::Topics::Delete

Inherits:
Base
  • Object
show all
Defined in:
lib/karafka/cli/topics/delete.rb

Overview

Deletes routing based topics

Instance Method Summary collapse

Methods included from Helpers::Colorize

#green, #grey, #red, #yellow

Instance Method Details

#callBoolean

Returns true if any topic was deleted, otherwise false.

Returns:

  • (Boolean)

    true if any topic was deleted, otherwise false



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/karafka/cli/topics/delete.rb', line 9

def call
  any_deleted = false

  declaratives_routing_topics.each do |topic|
    name = topic.name

    if existing_topics_names.include?(name)
      puts "Deleting topic #{name}..."
      Admin.delete_topic(name)
      puts "#{green('Deleted')} topic #{name}."
      any_deleted = true
    else
      puts "#{yellow('Skipping')} because topic #{name} does not exist."
    end
  end

  any_deleted
end