Sha256: 098b5eddf6c4e6c0aaab5c37151f6e47879d9b716f6c3d133c60791347bfc481

Contents?: true

Size: 1.17 KB

Versions: 7

Compression:

Stored size: 1.17 KB

Contents

# frozen_string_literal: true

module Karafka
  module Web
    module Management
      module Migrations
        module ConsumersMetrics
          # Since we have introduced notion of pause listeners, we need to reflect this in the
          # UI, so the scaling changes are visible
          class SplitListenersIntoActiveAndPaused < Base
            self.versions_until = '1.1.2'
            self.type = :consumers_metrics

            # @param state [Hash]
            def migrate(state)
              state[:aggregated].each_value do |metrics|
                metrics.each do |metric|
                  listeners = if metric.last.key?(:listeners)
                                metric.last[:listeners].to_i
                              elsif metric.last.key?(:listeners_count)
                                metric.last[:listeners_count].to_i
                              else
                                0
                              end

                  metric.last[:listeners] = {
                    active: listeners,
                    standby: 0
                  }
                end
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
karafka-web-0.10.3 lib/karafka/web/management/migrations/consumers_metrics/1704722380_split_listeners_into_active_and_paused.rb
karafka-web-0.10.2 lib/karafka/web/management/migrations/consumers_metrics/1704722380_split_listeners_into_active_and_paused.rb
karafka-web-0.10.1 lib/karafka/web/management/migrations/consumers_metrics/1704722380_split_listeners_into_active_and_paused.rb
karafka-web-0.10.0 lib/karafka/web/management/migrations/consumers_metrics/1704722380_split_listeners_into_active_and_paused.rb
karafka-web-0.10.0.rc2 lib/karafka/web/management/migrations/consumers_metrics/1704722380_split_listeners_into_active_and_paused.rb
karafka-web-0.10.0.rc1 lib/karafka/web/management/migrations/consumers_metrics/1704722380_split_listeners_into_active_and_paused.rb
karafka-web-0.10.0.beta1 lib/karafka/web/management/migrations/consumers_metrics/1704722380_split_listeners_into_active_and_paused.rb