module Karafka::Extensions::SidekiqTopicAttributes

Additional Karafka::Routing::Topic methods that are required to work with Sidekiq backend

Public Class Methods

included(base) click to toggle source

Creates attributes writers for worker and interchanger, so they can be overwritten @param base [Class] Karafka::Routing::Topic class

# 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

Public Instance Methods

interchanger() click to toggle source

@return [Class] Interchanger class (not an instance) that we want to use to interchange

params between Karafka server and Karafka background job
# File lib/karafka/extensions/sidekiq_topic_attributes.rb, line 16
def interchanger
  @interchanger ||= Karafka::Interchanger.new
end
worker() click to toggle source

@return [Class] Class (not an instance) of a worker that should be used to schedule the

background job

@note If not provided - will be built based on the provided consumer

# File lib/karafka/extensions/sidekiq_topic_attributes.rb, line 10
def worker
  @worker ||= backend == :sidekiq ? Karafka::Workers::Builder.new(consumer).build : nil
end