Module: Karafka::Pro::Routing::Features::ConsumerGroups::LongRunningJob::Topic
- Defined in:
- lib/karafka/pro/routing/features/consumer_groups/long_running_job/topic.rb
Overview
Long-Running Jobs topic API extensions
Instance Method Summary collapse
-
#initialize ⇒ Object
This method sets up the extra instance variable to nil before calling the parent class initializer.
- #long_running_job(active = false) ⇒ Object (also: #long_running)
-
#long_running_job? ⇒ Boolean
Is a given job on a topic a long-running one.
-
#to_h ⇒ Hash
Topic with all its native configuration options plus lrj.
Instance Method Details
#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.
43 44 45 46 |
# File 'lib/karafka/pro/routing/features/consumer_groups/long_running_job/topic.rb', line 43 def initialize(...) @long_running_job = nil super end |
#long_running_job(active = false) ⇒ Object Also known as: long_running
49 50 51 |
# File 'lib/karafka/pro/routing/features/consumer_groups/long_running_job/topic.rb', line 49 def long_running_job(active = false) @long_running_job ||= Config.new(active: active) end |
#long_running_job? ⇒ Boolean
Returns is a given job on a topic a long-running one.
56 57 58 |
# File 'lib/karafka/pro/routing/features/consumer_groups/long_running_job/topic.rb', line 56 def long_running_job? long_running_job.active? end |
#to_h ⇒ Hash
Returns topic with all its native configuration options plus lrj.
61 62 63 64 65 |
# File 'lib/karafka/pro/routing/features/consumer_groups/long_running_job/topic.rb', line 61 def to_h super.merge( long_running_job: long_running_job.to_h ).freeze end |