Sha256: e057984fb83830d6e26174d098c5855fdd4a604c67ca9ad70593fc43b08b43d9

Contents?: true

Size: 1.11 KB

Versions: 1

Compression:

Stored size: 1.11 KB

Contents

module Karafka
  # Karafka framework Cli
  class Cli
    # Routes Karafka Cli action
    class Routes < Base
      desc 'Print out all defined routes in alphabetical order'
      option aliases: 'r'

      # Print out all defined routes in alphabetical order
      def call
        routes.each do |route|
          puts "#{route.topic}:"
          print('Group', route.group)
          print('Controller', route.controller)
          print('Worker', route.worker)
          print('Parser', route.parser)
          print('Interchanger', route.interchanger)
          print('Responder', route.responder)
        end
      end

      private

      # @return [Array<Karafka::Routing::Route>] all routes sorted in alphabetical order
      def routes
        Karafka::App.routes.sort do |route1, route2|
          route1.topic <=> route2.topic
        end
      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 "%-18s %s\n", "  - #{label}:", value
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
karafka-0.5.0 lib/karafka/cli/routes.rb