Sha256: 6d533cbdcb53397be5d3f31d4bcd80153da185db22ca6999ea2652e1801762ef

Contents?: true

Size: 752 Bytes

Versions: 3

Compression:

Stored size: 752 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)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
karafka-sidekiq-backend-1.3.1 lib/karafka/extensions/params_batch_builder.rb
karafka-sidekiq-backend-1.3.0 lib/karafka/extensions/params_batch_builder.rb
karafka-sidekiq-backend-1.3.0.rc1 lib/karafka/extensions/params_batch_builder.rb