Class: Karafka::Web::Ui::Models::Status::Checks::StateCalculation

Inherits:
Base
  • Object
show all
Defined in:
lib/karafka/web/ui/models/status/checks/state_calculation.rb

Overview

Checks if there is a subscription to the reports topic being actively consumed.

The Web UI requires an active consumer processing the reports topic to calculate and update the state. This check verifies that subscription exists.

Instance Method Summary collapse

Methods inherited from Base

depends_on, halted_details, independent!, independent?, #initialize

Constructor Details

This class inherits a constructor from Karafka::Web::Ui::Models::Status::Checks::Base

Instance Method Details

#callStatus::Step

Executes the state calculation check.

Looks for the reports topic in the list of subscribed topics from the health data. Caches subscriptions in context.

Returns:

  • (Status::Step)

    success if subscribed, failure otherwise



23
24
25
26
27
28
29
30
31
32
# File 'lib/karafka/web/ui/models/status/checks/state_calculation.rb', line 23

def call
  context.subscriptions ||= Models::Health
    .current(context.current_state)
    .values.map { |consumer_group| consumer_group[:topics] }
    .flat_map(&:keys)

  subscribed = context.subscriptions.include?(context.topics_consumers_reports)

  step(subscribed ? :success : :failure)
end