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.2.7 lib/karafka/active_job/job_extensions.rb
karafka-2.2.6 lib/karafka/active_job/job_extensions.rb
karafka-2.2.5 lib/karafka/active_job/job_extensions.rb
karafka-2.2.4 lib/karafka/active_job/job_extensions.rb
karafka-2.2.3 lib/karafka/active_job/job_extensions.rb
karafka-2.2.2 lib/karafka/active_job/job_extensions.rb
karafka-2.2.1 lib/karafka/active_job/job_extensions.rb
karafka-2.2.0 lib/karafka/active_job/job_extensions.rb
karafka-2.1.13 lib/karafka/active_job/job_extensions.rb
karafka-2.1.12 lib/karafka/active_job/job_extensions.rb
karafka-2.1.11 lib/karafka/active_job/job_extensions.rb
karafka-2.1.10 lib/karafka/active_job/job_extensions.rb
karafka-2.1.9 lib/karafka/active_job/job_extensions.rb
karafka-2.1.8 lib/karafka/active_job/job_extensions.rb
karafka-2.1.7 lib/karafka/active_job/job_extensions.rb
karafka-2.1.6 lib/karafka/active_job/job_extensions.rb
karafka-2.1.5 lib/karafka/active_job/job_extensions.rb
karafka-2.1.5.beta1 lib/karafka/active_job/job_extensions.rb
karafka-2.1.4 lib/karafka/active_job/job_extensions.rb
karafka-2.1.3 lib/karafka/active_job/job_extensions.rb