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
24 25 26 27 28 |
# File 'lib/karafka/pro/routing/features/filtering/topic.rb', line 24 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.
31 32 33 |
# File 'lib/karafka/pro/routing/features/filtering/topic.rb', line 31 def filtering(*) filter(*) end |
#filtering? ⇒ Boolean
Returns is a given job throttled.
36 37 38 |
# File 'lib/karafka/pro/routing/features/filtering/topic.rb', line 36 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.
17 18 19 20 |
# File 'lib/karafka/pro/routing/features/filtering/topic.rb', line 17 def initialize(...) super @filtering = nil end |
#to_h ⇒ Hash
Returns topic with all its native configuration options plus throttling.
41 42 43 44 45 |
# File 'lib/karafka/pro/routing/features/filtering/topic.rb', line 41 def to_h super.merge( filtering: filtering.to_h ).freeze end |