Module: Karafka::Routing::Features::ConsumerGroups::InlineInsights::Topic

Defined in:
lib/karafka/routing/features/consumer_groups/inline_insights/topic.rb

Overview

Routing topic inline insights API

Instance Method Summary collapse

Instance Method Details

#initializeObject

This method sets up the extra instance variable to nil before calling the parent class initializer. The explicit initialization to nil is included as an optimization for Ruby’s object shapes system, which improves memory layout and access performance.



14
15
16
17
# File 'lib/karafka/routing/features/consumer_groups/inline_insights/topic.rb', line 14

def initialize(...)
  @inline_insights = nil
  super
end

#inline_insights(active = false) ⇒ Object

Parameters:

  • active (Boolean) (defaults to: false)

    should inline insights be activated



20
21
22
23
24
# File 'lib/karafka/routing/features/consumer_groups/inline_insights/topic.rb', line 20

def inline_insights(active = false)
  @inline_insights ||= Config.new(
    active: active
  )
end

#inline_insights?Boolean

Returns Are inline insights active.

Returns:

  • (Boolean)

    Are inline insights active



27
28
29
# File 'lib/karafka/routing/features/consumer_groups/inline_insights/topic.rb', line 27

def inline_insights?
  inline_insights.active?
end

#to_hHash

Returns topic setup hash.

Returns:

  • (Hash)

    topic setup hash



32
33
34
35
36
# File 'lib/karafka/routing/features/consumer_groups/inline_insights/topic.rb', line 32

def to_h
  super.merge(
    inline_insights: inline_insights.to_h
  ).freeze
end