Class: Karafka::Web::Management::Migrations::ConsumersReports::AddPollIntervalToSubscriptionGroups

Inherits:
Base
  • Object
show all
Defined in:
lib/karafka/web/management/migrations/consumers_reports/1772128000_add_poll_interval_to_subscription_groups.rb

Overview

Adds the poll_interval field to subscription group state

In schema versions before 1.7.0, subscription groups did not include the poll_interval field which tracks the max.poll.interval.ms configuration.

This migration ensures old reports can be processed by adding the field with the Kafka default value of 300000ms (5 minutes).

Constant Summary collapse

DEFAULT_POLL_INTERVAL_MS =

Reference the canonical default from Sampler to avoid duplication

::Karafka::Web::Tracking::Consumers::Sampler::DEFAULT_POLL_INTERVAL_MS

Instance Method Summary collapse

Methods inherited from Base

applicable?, index, migrate, sorted_descendants

Instance Method Details

#migrate(report) ⇒ Object

Parameters:

  • report (Hash)

    consumer report to migrate



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/karafka/web/management/migrations/consumers_reports/1772128000_add_poll_interval_to_subscription_groups.rb', line 23

def migrate(report)
  consumer_groups = report[:consumer_groups]

  return unless consumer_groups

  consumer_groups.each_value do |cg_details|
    subscription_groups = cg_details[:subscription_groups]

    next unless subscription_groups

    subscription_groups.each_value do |sg_details|
      state = sg_details[:state]

      next unless state
      next if state.key?(:poll_interval)

      state[:poll_interval] = DEFAULT_POLL_INTERVAL_MS
    end
  end
end