Module: Karafka::Extensions::ParamsBatchBuilder

Defined in:
lib/karafka/extensions/params_batch_builder.rb

Overview

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

Instance Method Summary collapse

Instance Method Details

#from_array(array, topic) ⇒ Karafka::Params::ParamsBatch

Note:

We rebuild the params batch from array after the serialization

Builds params batch from array of hashes

Parameters:

  • array (Array<Hash>)

    array with hash messages

  • topic (Karafka::Routing::Topic)

    topic for which we build the batch

Returns:

  • (Karafka::Params::ParamsBatch)

    built batch



12
13
14
15
16
17
18
# 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