Class: Karafka::Web::Ui::Models::Status::Step

Inherits:
Struct
  • Object
show all
Defined in:
lib/karafka/web/ui/models/status/step.rb

Overview

Represents the result of a single status check step.

Each check in the status flow returns a Step that contains:

  • The status of the check (:success, :warning, :failure, or :halted)

  • Optional details hash with check-specific information

Examples:

Creating a successful step

Step.new(:success, { time: 150 })

Creating a halted step (dependency failed)

Step.new(:halted, {})

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#detailsObject

Returns the value of attribute details

Returns:

  • (Object)

    the current value of details



19
20
21
# File 'lib/karafka/web/ui/models/status/step.rb', line 19

def details
  @details
end

#statusObject

Returns the value of attribute status

Returns:

  • (Object)

    the current value of status



19
20
21
# File 'lib/karafka/web/ui/models/status/step.rb', line 19

def status
  @status
end

Instance Method Details

#partial_namespaceString

Returns the partial namespace for rendering the appropriate view.

Maps the status to a directory name used for view partial lookup:

  • :success -> ‘successes’

  • :warning -> ‘warnings’

  • :failure -> ‘failures’

  • :halted -> ‘failures’ (halted checks show failure partial)

Returns:

  • (String)

    the partial namespace directory name

Raises:

  • (Karafka::Errors::UnsupportedCaseError)

    if status is unknown



40
41
42
43
44
45
46
47
48
49
# File 'lib/karafka/web/ui/models/status/step.rb', line 40

def partial_namespace
  case status
  when :success then "successes"
  when :warning then "warnings"
  when :failure then "failures"
  when :halted then "failures"
  else
    raise ::Karafka::Errors::UnsupportedCaseError, status
  end
end

#success?Boolean

Checks if the step completed successfully (allows chain to continue).

Both :success and :warning are considered successful because warnings don’t block the dependency chain - they just notify about potential issues.

Returns:

  • (Boolean)

    true if status is :success or :warning



26
27
28
# File 'lib/karafka/web/ui/models/status/step.rb', line 26

def success?
  %i[success warning].include?(status)
end

#to_sString

Returns the string representation of the status.

Used by views to dynamically select the appropriate partial template.

Returns:

  • (String)

    the status as a string



56
57
58
# File 'lib/karafka/web/ui/models/status/step.rb', line 56

def to_s
  status.to_s
end