Module: Karafka::Pro::Routing::Features::InlineInsights::Topic

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

Overview

Routing topic inline insights API

Instance Method Summary collapse

Instance Method Details

#inline_insights(active = -1,, required: -1)) ⇒ Object

Parameters:

  • active (Boolean) (defaults to: -1,)

    should inline insights be activated

  • required (Boolean) (defaults to: -1))

    are the insights required to operate



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/karafka/pro/routing/features/inline_insights/topic.rb', line 23

def inline_insights(active = -1, required: -1)
  # This weird style of checking allows us to activate inline insights in few ways:
  #   - inline_insights(true)
  #   - inline_insights(required: true)
  #   - inline_insights(required: false)
  #
  # In each of those cases inline insights will become active
  @inline_insights ||= begin
    config = Config.new(
      active: active == true || (active == -1 && required != -1),
      required: required == true
    )

    if config.active? && config.required?
      factory = lambda do |topic, partition|
        Pro::Processing::Filters::InlineInsightsDelayer.new(topic, partition)
      end

      filter(factory)
    end

    config
  end
end