Module: Karafka::Routing::Features::ConsumerGroups::DeadLetterQueue::Topic
- Defined in:
- lib/karafka/routing/features/consumer_groups/dead_letter_queue/topic.rb
Overview
DLQ topic extensions
Instance Method Summary collapse
-
#dead_letter_queue(max_retries: DEFAULT_MAX_RETRIES, topic: nil, independent: false, transactional: true, dispatch_method: :produce_async, marking_method: :mark_as_consumed, mark_after_dispatch: nil) ⇒ Config
Defined config.
-
#dead_letter_queue? ⇒ Boolean
Is the dlq active or not.
-
#initialize ⇒ Object
This method sets up the extra instance variable to nil before calling the parent class initializer.
-
#to_h ⇒ Hash
Topic with all its native configuration options plus dlq settings.
Instance Method Details
#dead_letter_queue(max_retries: DEFAULT_MAX_RETRIES, topic: nil, independent: false, transactional: true, dispatch_method: :produce_async, marking_method: :mark_as_consumed, mark_after_dispatch: nil) ⇒ Config
Returns defined config.
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/karafka/routing/features/consumer_groups/dead_letter_queue/topic.rb', line 39 def dead_letter_queue( max_retries: DEFAULT_MAX_RETRIES, topic: nil, independent: false, transactional: true, dispatch_method: :produce_async, marking_method: :mark_as_consumed, mark_after_dispatch: nil ) @dead_letter_queue ||= Config.new( active: !topic.nil?, max_retries: max_retries, topic: topic, independent: independent, transactional: transactional, dispatch_method: dispatch_method, marking_method: marking_method, mark_after_dispatch: mark_after_dispatch ) end |
#dead_letter_queue? ⇒ Boolean
Returns is the dlq active or not.
61 62 63 |
# File 'lib/karafka/routing/features/consumer_groups/dead_letter_queue/topic.rb', line 61 def dead_letter_queue? dead_letter_queue.active? end |
#initialize ⇒ Object
This method sets up the extra instance variable to nil before calling the parent class initializer. The explicit initialization to nil is included as an optimization for Ruby’s object shapes system, which improves memory layout and access performance.
19 20 21 22 |
# File 'lib/karafka/routing/features/consumer_groups/dead_letter_queue/topic.rb', line 19 def initialize(...) @dead_letter_queue = nil super end |
#to_h ⇒ Hash
Returns topic with all its native configuration options plus dlq settings.
66 67 68 69 70 |
# File 'lib/karafka/routing/features/consumer_groups/dead_letter_queue/topic.rb', line 66 def to_h super.merge( dead_letter_queue: dead_letter_queue.to_h ).freeze end |