Module: Karafka::Routing::Features::ConsumerGroups::ActiveJob::Topic
- Defined in:
- lib/karafka/routing/features/consumer_groups/active_job/topic.rb
Overview
ActiveJob topics do not have per-topic deserializer configuration. The deserializer is configured globally via ‘config.internal.active_job.deserializer` because Rails serializes jobs before dispatching them, requiring a consistent serialization format across all ActiveJob topics. If you need custom serialization (e.g., Avro, Protobuf), configure it once at the application level rather than per-topic.
Topic extensions to be able to check if given topic is ActiveJob topic
Instance Method Summary collapse
-
#active_job(active = false) ⇒ Object
where the boolean would be an argument.
-
#active_job? ⇒ Boolean
Is this an ActiveJob topic.
-
#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 active job namespace settings.
Instance Method Details
#active_job(active = false) ⇒ Object
Since this feature supports only one setting (active), we can use the old API
where the boolean would be an argument
29 30 31 |
# File 'lib/karafka/routing/features/consumer_groups/active_job/topic.rb', line 29 def active_job(active = false) @active_job ||= Config.new(active: active) end |
#active_job? ⇒ Boolean
Returns is this an ActiveJob topic.
34 35 36 |
# File 'lib/karafka/routing/features/consumer_groups/active_job/topic.rb', line 34 def active_job? active_job.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.
20 21 22 23 |
# File 'lib/karafka/routing/features/consumer_groups/active_job/topic.rb', line 20 def initialize(...) @active_job = nil super end |
#to_h ⇒ Hash
Returns topic with all its native configuration options plus active job namespace settings.
40 41 42 43 44 |
# File 'lib/karafka/routing/features/consumer_groups/active_job/topic.rb', line 40 def to_h super.merge( active_job: active_job.to_h ).freeze end |