Sha256: 5cc9b5558de36fa423a932e26a2c14de5135bf8ef4748b7c74553b640926f822

Contents?: true

Size: 1.23 KB

Versions: 21

Compression:

Stored size: 1.23 KB

Contents

# frozen_string_literal: true

module Karafka
  module Web
    class Cli
      # Base command for all the Web Cli commands
      class Base < Karafka::Cli::Base
        include ::Karafka::Helpers::Colorize

        class << self
          # @return [Array<Class>] available commands
          def commands
            ObjectSpace
              .each_object(Class)
              .select { |klass| klass.superclass == Karafka::Web::Cli::Base }
              .reject { |klass| klass.to_s.end_with?('::Base') }
              .sort_by(&:name)
          end
        end

        private

        # Takes the CLI user provided replication factor but if not present, uses the brokers count
        # to decide. For non-dev clusters (with one broker) we usually want to have replication of
        # two, just to have some redundancy.
        # @param cli_replication_factor [Integer, false] user requested replication factor or false
        #   if we are supposed to compute the factor automatically
        # @return [Integer] replication factor for Karafka Web UI topics
        def compute_replication_factor(cli_replication_factor)
          cli_replication_factor || (Ui::Models::ClusterInfo.fetch.brokers.size > 1 ? 2 : 1)
        end
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
karafka-web-0.10.4 lib/karafka/web/cli/base.rb
karafka-web-0.10.3 lib/karafka/web/cli/base.rb
karafka-web-0.10.2 lib/karafka/web/cli/base.rb
karafka-web-0.10.1 lib/karafka/web/cli/base.rb
karafka-web-0.10.0 lib/karafka/web/cli/base.rb
karafka-web-0.10.0.rc2 lib/karafka/web/cli/base.rb
karafka-web-0.10.0.rc1 lib/karafka/web/cli/base.rb
karafka-web-0.10.0.beta1 lib/karafka/web/cli/base.rb
karafka-web-0.9.1 lib/karafka/web/cli/base.rb
karafka-web-0.9.0 lib/karafka/web/cli/base.rb
karafka-web-0.9.0.rc3 lib/karafka/web/cli/base.rb
karafka-web-0.9.0.rc2 lib/karafka/web/cli/base.rb
karafka-web-0.9.0.rc1 lib/karafka/web/cli/base.rb
karafka-web-0.8.2 lib/karafka/web/cli/base.rb
karafka-web-0.8.1 lib/karafka/web/cli/base.rb
karafka-web-0.8.0 lib/karafka/web/cli/base.rb
karafka-web-0.8.0.rc1 lib/karafka/web/cli/base.rb
karafka-web-0.7.10 lib/karafka/web/cli/base.rb
karafka-web-0.7.9 lib/karafka/web/cli/base.rb
karafka-web-0.7.8 lib/karafka/web/cli/base.rb