Module: Karafka::Routing::Features::ActiveJob::Topic
- Defined in:
- lib/karafka/routing/features/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 calls the parent class initializer and then sets up the extra instance variable to nil.
-
#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
28 29 30 |
# File 'lib/karafka/routing/features/active_job/topic.rb', line 28 def active_job(active = false) @active_job ||= Config.new(active: active) end |
#active_job? ⇒ Boolean
Returns is this an ActiveJob topic.
33 34 35 |
# File 'lib/karafka/routing/features/active_job/topic.rb', line 33 def active_job? active_job.active? end |
#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.
19 20 21 22 |
# File 'lib/karafka/routing/features/active_job/topic.rb', line 19 def initialize(...) super @active_job = nil end |
#to_h ⇒ Hash
Returns topic with all its native configuration options plus active job namespace settings.
39 40 41 42 43 |
# File 'lib/karafka/routing/features/active_job/topic.rb', line 39 def to_h super.merge( active_job: active_job.to_h ).freeze end |