Sha256: 40b421ac28fbc7720521f7f21bbc529f32a559b61833f0c3cd21d239e3ca2239

Contents?: true

Size: 1.18 KB

Versions: 12

Compression:

Stored size: 1.18 KB

Contents

# frozen_string_literal: true

module Karafka
  module Web
    module Ui
      module Controllers
        # Selects cluster info and topics basic info
        class Cluster < Base
          # List cluster info data
          def index
            @cluster_info = Karafka::Admin.cluster_info

            partitions_total = []

            displayable_topics(@cluster_info).each do |topic|
              topic[:partitions].each do |partition|
                partitions_total << partition.merge(topic: topic)
              end
            end

            @partitions, @next_page = Ui::Lib::PaginateArray.new.call(
              partitions_total,
              @params.current_page
            )

            respond
          end

          private

          # @param cluster_info [Rdkafka::Metadata] cluster metadata
          # @return [Array<Hash>] array with topics to be displayed sorted in an alphabetical
          #   order
          def displayable_topics(cluster_info)
            cluster_info
              .topics
              .reject { |topic| topic[:topic_name] == '__consumer_offsets' }
              .sort_by { |topic| topic[:topic_name] }
          end
        end
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
karafka-web-0.6.3 lib/karafka/web/ui/controllers/cluster.rb
karafka-web-0.6.1 lib/karafka/web/ui/controllers/cluster.rb
karafka-web-0.6.0 lib/karafka/web/ui/controllers/cluster.rb
karafka-web-0.5.2 lib/karafka/web/ui/controllers/cluster.rb
karafka-web-0.5.1 lib/karafka/web/ui/controllers/cluster.rb
karafka-web-0.5.0 lib/karafka/web/ui/controllers/cluster.rb
karafka-web-0.4.1 lib/karafka/web/ui/controllers/cluster.rb
karafka-web-0.4.0 lib/karafka/web/ui/controllers/cluster.rb
karafka-web-0.3.1 lib/karafka/web/ui/controllers/cluster.rb
karafka-web-0.3.0 lib/karafka/web/ui/controllers/cluster.rb
karafka-web-0.2.5 lib/karafka/web/ui/controllers/cluster.rb
karafka-web-0.2.4 lib/karafka/web/ui/controllers/cluster.rb