class Karafka::Cli::Flow

Description of topics flow (incoming/outgoing)

Public Instance Methods

call() click to toggle source

Print out all defined routes in alphabetical order

# File lib/karafka/cli/flow.rb, line 11
def call
  topics.each do |topic|
    any_topics = !topic.responder&.topics.nil?
    log_messages = []

    if any_topics
      log_messages << "#{topic.name} =>"

      topic.responder.topics.each_value do |responder_topic|
        features = []
        features << (responder_topic.required? ? 'always' : 'conditionally')

        log_messages << format(responder_topic.name, "(#{features.join(', ')})")
      end
    else
      log_messages << "#{topic.name} => (nothing)"
    end

    Karafka.logger.info(log_messages.join("\n"))
  end
end

Private Instance Methods

format(label, value) click to toggle source

Formats a given value with label in a nice way @param label [String] label describing value @param value [String] value that should be printed

# File lib/karafka/cli/flow.rb, line 43
def format(label, value)
  "  - #{label}:                #{value}"
end
topics() click to toggle source

@return [Array<Karafka::Routing::Topic>] all topics sorted in alphabetical order

# File lib/karafka/cli/flow.rb, line 36
def topics
  Karafka::App.consumer_groups.map(&:topics).flatten.sort_by(&:name)
end