Module: Karafka::Extensions::SidekiqTopicAttributes
- Defined in:
- lib/karafka/extensions/sidekiq_topic_attributes.rb
Overview
Additional Karafka::Routing::Topic methods that are required to work with Sidekiq backend
Class Method Summary collapse
-
.included(base) ⇒ Object
Creates attributes writers for worker and interchanger, so they can be overwritten.
Instance Method Summary collapse
-
#interchanger ⇒ #encode, #decode
Interchanger instance (not a class) that we want to use to interchange params between Karafka server and Karafka background job.
-
#worker ⇒ Class
Class (not an instance) of a worker that should be used to schedule the background job.
Class Method Details
.included(base) ⇒ Object
Creates attributes writers for worker and interchanger, so they can be overwritten
22 23 24 25 |
# File 'lib/karafka/extensions/sidekiq_topic_attributes.rb', line 22 def self.included(base) base.send :attr_writer, :worker base.send :attr_writer, :interchanger end |
Instance Method Details
#interchanger ⇒ #encode, #decode
Returns Interchanger instance (not a class) that we want to use to interchange params between Karafka server and Karafka background job.
16 17 18 |
# File 'lib/karafka/extensions/sidekiq_topic_attributes.rb', line 16 def interchanger @interchanger ||= Karafka::Interchanger.new end |
#worker ⇒ Class
If not provided - will be built based on the provided consumer
Returns Class (not an instance) of a worker that should be used to schedule the background job.
10 11 12 |
# File 'lib/karafka/extensions/sidekiq_topic_attributes.rb', line 10 def worker @worker ||= backend == :sidekiq ? Karafka::Workers::Builder.new(consumer).build : nil end |