Sha256: 345a2b11f67b308f62a97976c2fc5f82a0807f8783ced99935130d25d1b1eb4c

Contents?: true

Size: 708 Bytes

Versions: 58

Compression:

Stored size: 708 Bytes

Contents

# frozen_string_literal: true

module Karafka
  module ActiveJob
    module CurrentAttributes
      # Module adding the current attributes persistence into the ActiveJob jobs
      module Persistence
        # Alters the job serialization to inject the current attributes into the json before we
        # send it to Kafka
        #
        # @param job [ActiveJob::Base] job
        def serialize_job(job)
          json = super(job)

          _cattr_klasses.each do |key, cattr_klass_str|
            next if json.key?(key)

            attrs = cattr_klass_str.constantize.attributes

            json[key] = attrs unless attrs.empty?
          end

          json
        end
      end
    end
  end
end

Version data entries

58 entries across 58 versions & 1 rubygems

Version Path
karafka-2.4.17 lib/karafka/active_job/current_attributes/persistence.rb
karafka-2.4.16 lib/karafka/active_job/current_attributes/persistence.rb
karafka-2.4.15 lib/karafka/active_job/current_attributes/persistence.rb
karafka-2.4.14 lib/karafka/active_job/current_attributes/persistence.rb
karafka-2.4.13 lib/karafka/active_job/current_attributes/persistence.rb
karafka-2.4.12 lib/karafka/active_job/current_attributes/persistence.rb
karafka-2.4.11 lib/karafka/active_job/current_attributes/persistence.rb
karafka-2.4.10 lib/karafka/active_job/current_attributes/persistence.rb
karafka-2.4.9 lib/karafka/active_job/current_attributes/persistence.rb
karafka-2.4.8 lib/karafka/active_job/current_attributes/persistence.rb
karafka-2.4.7 lib/karafka/active_job/current_attributes/persistence.rb
karafka-2.4.6 lib/karafka/active_job/current_attributes/persistence.rb
karafka-2.4.5 lib/karafka/active_job/current_attributes/persistence.rb
karafka-2.4.4 lib/karafka/active_job/current_attributes/persistence.rb
karafka-2.4.3 lib/karafka/active_job/current_attributes/persistence.rb
karafka-2.4.0 lib/karafka/active_job/current_attributes/persistence.rb
karafka-2.4.0.rc1 lib/karafka/active_job/current_attributes/persistence.rb
karafka-2.3.4 lib/karafka/active_job/current_attributes/persistence.rb
karafka-2.4.0.beta2 lib/karafka/active_job/current_attributes/persistence.rb
karafka-2.4.0.beta1 lib/karafka/active_job/current_attributes/persistence.rb