Module: Karafka::Messages::Builders::BatchMetadata
- Defined in:
- lib/karafka/messages/builders/batch_metadata.rb
Overview
Builder for creating batch metadata object based on the batch informations.
Class Method Summary collapse
-
.call(messages, topic, partition, scheduled_at) ⇒ Karafka::Messages::BatchMetadata
Creates metadata based on the kafka batch data.
Class Method Details
.call(messages, topic, partition, scheduled_at) ⇒ Karafka::Messages::BatchMetadata
Note:
We do not set ‘processed_at` as this needs to be assigned when the batch is picked up for processing.
Creates metadata based on the kafka batch data.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/karafka/messages/builders/batch_metadata.rb', line 19 def call(, topic, partition, scheduled_at) Karafka::Messages::BatchMetadata.new( size: .count, first_offset: .first&.offset || -1001, last_offset: .last&.offset || -1001, deserializers: topic.deserializers, partition: partition, topic: topic.name, # We go with the assumption that the creation of the whole batch is the last message # creation time created_at: local_created_at(.last), # When this batch was built and scheduled for execution scheduled_at: scheduled_at, # This needs to be set to a correct value prior to processing starting processed_at: nil ) end |