Module: Karafka::Pro::Routing::Features::Filtering::Topic
- Defined in:
- lib/karafka/pro/routing/features/filtering/topic.rb
Overview
Filtering feature topic extensions
Instance Method Summary collapse
- #filter(factory = nil) ⇒ Object
-
#filtering ⇒ Filtering::Config
Alias to match the naming API for features.
-
#filtering? ⇒ Boolean
Is a given job throttled.
-
#initialize ⇒ Object
This method calls the parent class initializer and then sets up the extra instance variable to nil.
-
#to_h ⇒ Hash
Topic with all its native configuration options plus throttling.
Instance Method Details
#filter(factory = nil) ⇒ Object
41 42 43 44 45 |
# File 'lib/karafka/pro/routing/features/filtering/topic.rb', line 41 def filter(factory = nil) @filtering ||= Config.new(factories: []) @filtering.factories << factory if factory @filtering end |
#filtering ⇒ Filtering::Config
Returns alias to match the naming API for features.
48 49 50 |
# File 'lib/karafka/pro/routing/features/filtering/topic.rb', line 48 def filtering(*) filter(*) end |
#filtering? ⇒ Boolean
Returns is a given job throttled.
53 54 55 |
# File 'lib/karafka/pro/routing/features/filtering/topic.rb', line 53 def filtering? filtering.active? end |
#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.
34 35 36 37 |
# File 'lib/karafka/pro/routing/features/filtering/topic.rb', line 34 def initialize(...) super @filtering = nil end |
#to_h ⇒ Hash
Returns topic with all its native configuration options plus throttling.
58 59 60 61 62 |
# File 'lib/karafka/pro/routing/features/filtering/topic.rb', line 58 def to_h super.merge( filtering: filtering.to_h ).freeze end |