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.4.0 lib/karafka/active_job/job_extensions.rb
karafka-2.4.0.rc1 lib/karafka/active_job/job_extensions.rb
karafka-2.3.4 lib/karafka/active_job/job_extensions.rb
karafka-2.4.0.beta2 lib/karafka/active_job/job_extensions.rb
karafka-2.4.0.beta1 lib/karafka/active_job/job_extensions.rb
karafka-2.3.3 lib/karafka/active_job/job_extensions.rb
karafka-2.3.2 lib/karafka/active_job/job_extensions.rb
karafka-2.3.1 lib/karafka/active_job/job_extensions.rb
karafka-2.3.0 lib/karafka/active_job/job_extensions.rb
karafka-2.3.0.rc1 lib/karafka/active_job/job_extensions.rb
karafka-2.3.0.alpha2 lib/karafka/active_job/job_extensions.rb
karafka-2.3.0.alpha1 lib/karafka/active_job/job_extensions.rb
karafka-2.2.14 lib/karafka/active_job/job_extensions.rb
karafka-2.2.13 lib/karafka/active_job/job_extensions.rb
karafka-2.2.12 lib/karafka/active_job/job_extensions.rb
karafka-2.2.11 lib/karafka/active_job/job_extensions.rb
karafka-2.2.10 lib/karafka/active_job/job_extensions.rb
karafka-2.2.9 lib/karafka/active_job/job_extensions.rb
karafka-2.2.8 lib/karafka/active_job/job_extensions.rb
karafka-2.2.8.beta1 lib/karafka/active_job/job_extensions.rb