Sha256: 727ff923dbc60f5a8e3c0af70c8cf3afb6484b7b5202ee1477b6f431eac8eeb7

Contents?: true

Size: 1.01 KB

Versions: 100

Compression:

Stored size: 1.01 KB

Contents

# frozen_string_literal: true

module Karafka
  module ActiveJob
    # Allows for setting karafka specific options in ActiveJob jobs
    module JobExtensions
      class << self
        # Defines all the needed accessors and sets defaults
        # @param klass [ActiveJob::Base] active job base
        def extended(klass)
          klass.class_attribute :_karafka_options
          klass._karafka_options = {}
        end
      end

      # @param new_options [Hash] additional options that allow for jobs Karafka related options
      #   customization
      # @return [Hash] karafka options
      def karafka_options(new_options = {})
        return _karafka_options if new_options.empty?

        # Make sure, that karafka options that someone wants to use are valid before assigning
        # them
        App.config.internal.active_job.job_options_contract.validate!(new_options)

        new_options.each do |name, value|
          _karafka_options[name] = value
        end

        _karafka_options
      end
    end
  end
end

Version data entries

100 entries across 100 versions & 1 rubygems

Version Path
karafka-2.0.23 lib/karafka/active_job/job_extensions.rb
karafka-2.0.22 lib/karafka/active_job/job_extensions.rb
karafka-2.0.21 lib/karafka/active_job/job_extensions.rb
karafka-2.0.20 lib/karafka/active_job/job_extensions.rb
karafka-2.0.19 lib/karafka/active_job/job_extensions.rb
karafka-2.0.18 lib/karafka/active_job/job_extensions.rb
karafka-2.0.17 lib/karafka/active_job/job_extensions.rb
karafka-2.0.16 lib/karafka/active_job/job_extensions.rb
karafka-2.0.15 lib/karafka/active_job/job_extensions.rb
karafka-2.0.14 lib/karafka/active_job/job_extensions.rb
karafka-2.0.13 lib/karafka/active_job/job_extensions.rb
karafka-2.0.12 lib/karafka/active_job/job_extensions.rb
karafka-2.0.11 lib/karafka/active_job/job_extensions.rb
karafka-2.0.10 lib/karafka/active_job/job_extensions.rb
karafka-2.0.9 lib/karafka/active_job/job_extensions.rb
karafka-2.0.8 lib/karafka/active_job/job_extensions.rb
karafka-2.0.7 lib/karafka/active_job/job_extensions.rb
karafka-2.0.6 lib/karafka/active_job/job_extensions.rb
karafka-2.0.5 lib/karafka/active_job/job_extensions.rb
karafka-2.0.4 lib/karafka/active_job/job_extensions.rb