Module: Karafka::Web::Ui::Models::Processes

Extended by:
Core::Helpers::Time
Defined in:
lib/karafka/web/ui/models/processes.rb

Overview

Note:

Active also includes processes stopped recently. We use it to provide better visibility via UI.

Represents the active processes data

Class Method Summary collapse

Class Method Details

.active(state) ⇒ Array<Process>

Returns the active processes in an array and alongside of that the current state of the system. We use those together in the UI and it would be expensive to pick it up while we’ve already had it. Active means it is running (or recently shutdown) and it has current schema. Basically any process about which we can reason

Parameters:

  • state (State)

    current system state from which we can get processes metadata

Returns:



34
35
36
# File 'lib/karafka/web/ui/models/processes.rb', line 34

def active(state)
  all(state).delete_if { |process| !process.schema_compatible? }
end

.all(state) ⇒ Array<Process>

Returns processes that are running or recently shutdown. It may also return processes with incompatible schema.

Parameters:

  • state (State)

    current system state from which we can get processes metadata

Returns:



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

def all(state)
  messages = fetch_reports(state)
  messages = squash_processes_data(messages)
  processes = messages.map(&:payload)
  evict_expired_processes(processes)
  processes = sort_processes(processes)
  processes.map { |process_hash| Process.new(process_hash) }
end