Sha256: 87b826cfc2581862c00f8345ec18104c17a6160774f03c5184b0cbcd303280ae

Contents?: true

Size: 1.36 KB

Versions: 24

Compression:

Stored size: 1.36 KB

Contents

# frozen_string_literal: true

module Karafka
  # Karafka framework Cli
  class Cli < Thor
    # Description of topics flow (incoming/outgoing)
    class Flow < Base
      desc 'Print application data flow (incoming => outgoing)'

      # Print out all defined routes in alphabetical order
      def call
        topics.each do |topic|
          any_topics = !topic.responder&.topics.nil?

          if any_topics
            puts "#{topic.name} =>"

            topic.responder.topics.each_value do |responder_topic|
              features = []
              features << (responder_topic.required? ? 'always' : 'conditionally')
              features << (responder_topic.multiple_usage? ? 'one or more' : 'exactly once')

              print responder_topic.name, "(#{features.join(', ')})"
            end
          else
            puts "#{topic.name} => (nothing)"
          end
        end
      end

      private

      # @return [Array<Karafka::Routing::Topic>] all topics sorted in alphabetical order
      def topics
        Karafka::App.consumer_groups.map(&:topics).flatten.sort_by(&:name)
      end

      # Prints a given value with label in a nice way
      # @param label [String] label describing value
      # @param value [String] value that should be printed
      def print(label, value)
        printf "%-25s %s\n", "  - #{label}:", value
      end
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
karafka-1.2.13 lib/karafka/cli/flow.rb
karafka-1.2.12 lib/karafka/cli/flow.rb
karafka-1.2.11 lib/karafka/cli/flow.rb
karafka-1.2.10 lib/karafka/cli/flow.rb
karafka-1.2.9 lib/karafka/cli/flow.rb
karafka-1.2.8 lib/karafka/cli/flow.rb
karafka-1.2.7 lib/karafka/cli/flow.rb
karafka-1.2.6 lib/karafka/cli/flow.rb
karafka-1.2.5 lib/karafka/cli/flow.rb
karafka-1.2.4 lib/karafka/cli/flow.rb
karafka-1.2.3 lib/karafka/cli/flow.rb
karafka-1.2.2 lib/karafka/cli/flow.rb
karafka-1.2.1 lib/karafka/cli/flow.rb
karafka-1.2.0 lib/karafka/cli/flow.rb
karafka-1.2.0.beta4 lib/karafka/cli/flow.rb
karafka-1.2.0.beta3 lib/karafka/cli/flow.rb
karafka-1.2.0.beta2 lib/karafka/cli/flow.rb
karafka-1.2.0.beta1 lib/karafka/cli/flow.rb
karafka-1.1.2 lib/karafka/cli/flow.rb
karafka-1.1.1 lib/karafka/cli/flow.rb