Class: Karafka::Web::Ui::Models::ConsumersMetrics

Inherits:
Lib::HashProxy show all
Defined in:
lib/karafka/web/ui/models/consumers_metrics.rb

Overview

Model representing the current consumers metrics most recent state

Class Method Summary collapse

Methods inherited from Lib::HashProxy

#initialize, #method_missing, #respond_to_missing?, #to_h

Constructor Details

This class inherits a constructor from Karafka::Web::Ui::Lib::HashProxy

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Karafka::Web::Ui::Lib::HashProxy

Class Method Details

.currentState, false

Returns current consumers metrics or false if not found.

Returns:

  • (State, false)

    current consumers metrics or false if not found



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/karafka/web/ui/models/consumers_metrics.rb', line 11

def current
  state = fetch

  return false unless state

  # Do not return the state in case web-ui is not enabled because we need our
  # internal deserializer for it to operate. False will force user to go to the
  # status page
  return false unless Models::Status.new.enabled.success?

  state = state.payload
  new(state)
end

.current!State

Returns current consumers metrics.

Returns:

  • (State)

    current consumers metrics

Raises:



27
28
29
# File 'lib/karafka/web/ui/models/consumers_metrics.rb', line 27

def current!
  current || raise(::Karafka::Web::Errors::Ui::NotFoundError)
end