Sha256: 880301ca730c71bbaed8c3411ad2b20db6696bde5c24229d7a6b7d4d97e02f5e

Contents?: true

Size: 1.04 KB

Versions: 6

Compression:

Stored size: 1.04 KB

Contents

# frozen_string_literal: true

module Karafka
  module Extensions
    # Additional Karafka::Routing::Topic methods that are required to work with Sidekiq backend
    module SidekiqTopicAttributes
      # @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
      def worker
        @worker ||= backend == :sidekiq ? Karafka::Workers::Builder.new(consumer).build : nil
      end

      # @return [#encode, #decode] Interchanger instance (not a class) that we want to use to
      #   interchange params between Karafka server and Karafka background job
      def interchanger
        @interchanger ||= Karafka::Interchanger.new
      end

      # Creates attributes writers for worker and interchanger, so they can be overwritten
      # @param base [Class] Karafka::Routing::Topic class
      def self.included(base)
        base.send :attr_writer, :worker
        base.send :attr_writer, :interchanger
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
karafka-sidekiq-backend-1.4.9 lib/karafka/extensions/sidekiq_topic_attributes.rb
karafka-sidekiq-backend-1.4.7 lib/karafka/extensions/sidekiq_topic_attributes.rb
karafka-sidekiq-backend-1.4.6 lib/karafka/extensions/sidekiq_topic_attributes.rb
karafka-sidekiq-backend-1.4.5 lib/karafka/extensions/sidekiq_topic_attributes.rb
karafka-sidekiq-backend-1.4.4 lib/karafka/extensions/sidekiq_topic_attributes.rb
karafka-sidekiq-backend-1.4.3 lib/karafka/extensions/sidekiq_topic_attributes.rb