Sha256: eb13463e115304c7373a10b66bee091176eca63623a90b174b1dcbc3081d1d5e

Contents?: true

Size: 758 Bytes

Versions: 9

Compression:

Stored size: 758 Bytes

Contents

# frozen_string_literal: true

module Karafka
  module Extensions
    # Extension for params batch builder for reconstruction of the batch from an array
    module ParamsBatchBuilder
      # Builds params batch from array of hashes
      # @param array [Array<Hash>] array with hash messages
      # @param topic [Karafka::Routing::Topic] topic for which we build the batch
      # @return [Karafka::Params::ParamsBatch] built batch
      # @note We rebuild the params batch from array after the serialization
      def from_array(array, topic)
        params_array = array.map do |hash|
          Karafka::Params::Builders::Params.from_hash(hash, topic)
        end

        Karafka::Params::ParamsBatch.new(params_array).freeze
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
karafka-sidekiq-backend-1.4.9 lib/karafka/extensions/params_batch_builder.rb
karafka-sidekiq-backend-1.4.7 lib/karafka/extensions/params_batch_builder.rb
karafka-sidekiq-backend-1.4.6 lib/karafka/extensions/params_batch_builder.rb
karafka-sidekiq-backend-1.4.5 lib/karafka/extensions/params_batch_builder.rb
karafka-sidekiq-backend-1.4.4 lib/karafka/extensions/params_batch_builder.rb
karafka-sidekiq-backend-1.4.3 lib/karafka/extensions/params_batch_builder.rb
karafka-sidekiq-backend-1.4.2 lib/karafka/extensions/params_batch_builder.rb
karafka-sidekiq-backend-1.4.1 lib/karafka/extensions/params_batch_builder.rb
karafka-sidekiq-backend-1.4.0 lib/karafka/extensions/params_batch_builder.rb