Class: Karafka::Web::Ui::Models::State

Inherits:
Lib::HashProxy show all
Extended by:
Core::Helpers::Time
Defined in:
lib/karafka/web/ui/models/state.rb

Overview

Represents the current consumer processes aggregated state This state is the core of Karafka reporting. It holds the most important aggregated data as well as pointers to states of particular consumers and their details.

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

Note:

Current state may contain expired data, for example of processes that were forcefully killed, etc. We clean this prior to returning the state.

Returns current aggregated state or false if not found.

Returns:

  • (State, false)

    current aggregated state or false if not found



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/karafka/web/ui/models/state.rb', line 17

def current
  state = fetch

  return false unless state

  state = state.payload
  evict_expired_processes(state)
  sort_processes(state)

  new(state)
end

.current!State

Returns current aggregated state.

Returns:

  • (State)

    current aggregated state

Raises:



32
33
34
# File 'lib/karafka/web/ui/models/state.rb', line 32

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