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
30 31 32 |
# File 'lib/karafka/routing/features/consumer_groups/active_job/topic.rb', line 30 def active_job(active = false) @active_job ||= Config.new(active: active) end |
#active_job? ⇒ Boolean
Returns is this an ActiveJob topic.
35 36 37 |
# File 'lib/karafka/routing/features/consumer_groups/active_job/topic.rb', line 35 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.
21 22 23 24 |
# File 'lib/karafka/routing/features/consumer_groups/active_job/topic.rb', line 21 def initialize(...) @active_job = nil super end |
#to_h ⇒ Hash
Returns topic with all its native configuration options plus active job namespace settings.
41 42 43 44 45 |
# File 'lib/karafka/routing/features/consumer_groups/active_job/topic.rb', line 41 def to_h super.merge( active_job: active_job.to_h ).freeze end |