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

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

Overview

Note:

Low replication is only a warning in production environments. In non-production environments, replication of 1 is acceptable.

Checks if topics have adequate replication factors.

In production environments, replication factor < 2 is a potential problem because data could be lost if a broker fails. This check warns about low replication but doesn’t fail because it’s not critical for functionality.

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

depends_on, independent!, independent?, #initialize

Constructor Details

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

Class Method Details

.halted_detailsHash

Returns empty hash for halted state.

Returns:

  • (Hash)

    empty hash for halted state



23
24
25
# File 'lib/karafka/web/ui/models/status/checks/replication.rb', line 23

def halted_details
  {}
end

Instance Method Details

#callStatus::Step

Executes the replication check.

Verifies that all topics have replication factor >= 2 in production.

Returns:

  • (Status::Step)

    result with topic details including replication factors



33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/karafka/web/ui/models/status/checks/replication.rb', line 33

def call
  details = context.topics_details

  status = :success
  # Low replication is not an error but just a warning and a potential problem
  # in case of a crash, this is why we do not fail but warn only
  status = :warning if details.values.any? { |det| det[:replication] < 2 }
  # Allow for non-production setups to use replication 1 as it is not that relevant
  status = :success unless Karafka.env.production?

  step(status, details)
end