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.
42 43 44 45 |
# File 'lib/karafka/pro/routing/features/inline_insights/topic.rb', line 42 def initialize(...) super @inline_insights = nil end |
#inline_insights(active = -1,, required: -1)) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/karafka/pro/routing/features/inline_insights/topic.rb', line 49 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 |