Module: Karafka::Messages::Builders::Messages

Defined in:
lib/karafka/messages/builders/messages.rb

Overview

Builder for creating message batch instances.

Class Method Summary collapse

Class Method Details

.call(messages, topic, partition, received_at) ⇒ Karafka::Messages::Messages

Creates messages batch with messages inside based on the incoming messages and the topic from which it comes.

Parameters:

  • messages (Array<Karafka::Messages::Message>)

    karafka messages array

  • topic (Karafka::Routing::Topic)

    topic for which we’re received messages

  • partition (Integer)

    partition of those messages

  • received_at (Time)

    moment in time when the messages were received

Returns:



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/karafka/messages/builders/messages.rb', line 17

def call(messages, topic, partition, received_at)
  # We cannot freeze the batch metadata because it is altered with the processed_at time
  # prior to the consumption. It is being frozen there
   = BatchMetadata.call(
    messages,
    topic,
    partition,
    received_at
  )

  Karafka::Messages::Messages.new(
    messages,
    
  ).freeze
end