module Karafka::Extensions::ParamsBatchBuilder

Extension for params batch builder for reconstruction of the batch from an array

Public Instance Methods

from_array(array, topic) click to toggle source

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

# File lib/karafka/extensions/params_batch_builder.rb, line 12
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