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
-
#initialize ⇒ Object
This method calls the parent class initializer and then sets up the extra instance variable to nil.
-
#inline_insights(active = -1,, required: -1)) ⇒ Object
Instance Method Details
#initialize ⇒ Object
This method calls the parent class initializer and then sets up the extra instance variable to nil. The explicit initialization to nil is included as an optimization for Ruby’s object shapes system, which improves memory layout and access performance.
17 18 19 20 |
# File 'lib/karafka/pro/routing/features/inline_insights/topic.rb', line 17 def initialize(...) super @inline_insights = nil end |
#inline_insights(active = -1,, required: -1)) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/karafka/pro/routing/features/inline_insights/topic.rb', line 24 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 |