Module: Karafka::Routing::Features::ManualOffsetManagement::Topic
- Defined in:
- lib/karafka/routing/features/manual_offset_management/topic.rb
Overview
Topic extensions to be able to manage manual offset management settings
Instance Method Summary collapse
-
#initialize ⇒ Object
This method calls the parent class initializer and then sets up the extra instance variable to nil.
-
#manual_offset_management(active = false) ⇒ Config
where the boolean would be an argument.
-
#manual_offset_management? ⇒ Boolean
Is manual offset management enabled for a given topic.
-
#to_h ⇒ Hash
Topic with all its native configuration options plus manual offset management namespace settings.
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.
13 14 15 16 |
# File 'lib/karafka/routing/features/manual_offset_management/topic.rb', line 13 def initialize(...) super @manual_offset_management = nil end |
#manual_offset_management(active = false) ⇒ Config
Since this feature supports only one setting (active), we can use the old API
where the boolean would be an argument
24 25 26 |
# File 'lib/karafka/routing/features/manual_offset_management/topic.rb', line 24 def manual_offset_management(active = false) @manual_offset_management ||= Config.new(active: active) end |
#manual_offset_management? ⇒ Boolean
Returns is manual offset management enabled for a given topic.
29 30 31 |
# File 'lib/karafka/routing/features/manual_offset_management/topic.rb', line 29 def manual_offset_management? manual_offset_management.active? end |
#to_h ⇒ Hash
Returns topic with all its native configuration options plus manual offset management namespace settings.
35 36 37 38 39 |
# File 'lib/karafka/routing/features/manual_offset_management/topic.rb', line 35 def to_h super.merge( manual_offset_management: manual_offset_management.to_h ).freeze end |