Class: Karafka::Web::Pro::Ui::Controllers::ErrorsController

Inherits:
BaseController show all
Defined in:
lib/karafka/web/pro/ui/controllers/errors_controller.rb

Overview

Errors details controller

Constant Summary

Constants inherited from Ui::Controllers::BaseController

Ui::Controllers::BaseController::Models

Instance Attribute Summary

Attributes inherited from Ui::Controllers::BaseController

#params, #session

Instance Method Summary collapse

Methods inherited from Ui::Controllers::BaseController

#cache, #initialize

Methods included from Ui::Controllers::Requests::Hookable

included, #run_after_hooks, #run_before_hooks

Constructor Details

This class inherits a constructor from Karafka::Web::Ui::Controllers::BaseController

Instance Method Details

#index ⇒ Object

Lists all the errors from all the partitions



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/karafka/web/pro/ui/controllers/errors_controller.rb', line 39

def index
  @topic_id = errors_topic
  @partitions_count = Models::ClusterInfo.partitions_count(errors_topic)

  @active_partitions, materialized_page, @limited = Paginators::Partitions.call(
    @partitions_count, @params.current_page
  )

  @error_messages, next_page = Models::Message.topic_page(
    errors_topic, @active_partitions, materialized_page
  )

  paginate(@params.current_page, next_page)

  render
end

#partition(partition_id) ⇒ Object

Parameters:

  • partition_id (Integer) —

    id of the partition of errors we are interested in



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/karafka/web/pro/ui/controllers/errors_controller.rb', line 57

def partition(partition_id)
  @topic_id = errors_topic
  @partition_id = partition_id
  @watermark_offsets = Models::WatermarkOffsets.find(errors_topic, @partition_id)
  @partitions_count = Models::ClusterInfo.partitions_count(errors_topic)

  previous_offset, @error_messages, next_offset = Models::Message.offset_page(
    errors_topic,
    @partition_id,
    @params.current_offset,
    @watermark_offsets
  )

  # If message is an array, it means it's a compacted dummy offset representation
  mapped = @error_messages.map do |message|
    message.is_a?(Array) ? message.last : message.offset
  end

  paginate(previous_offset, @params.current_offset, next_offset, mapped)

  render
end

#show(partition_id, offset) ⇒ Object

Shows given error details

Parameters:

  • partition_id (Integer)
  • offset (Integer)


84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/karafka/web/pro/ui/controllers/errors_controller.rb', line 84

def show(partition_id, offset)
  @partition_id = partition_id
  @offset = offset

  watermark_offsets = Models::WatermarkOffsets.find(errors_topic, partition_id)

  @error_message = Models::Message.find(
    errors_topic,
    partition_id,
    offset,
    watermark_offsets: watermark_offsets
  )

  paginate(offset, watermark_offsets.low, watermark_offsets.high)

  render
end