Module: Karafka::Messages::Builders::Message
- Defined in:
- lib/karafka/messages/builders/message.rb
Overview
Builder of a single message based on raw rdkafka message.
Class Method Summary collapse
-
.call(kafka_message, topic, received_at) ⇒ Karafka::Messages::Message
Message object with payload and metadata.
Class Method Details
.call(kafka_message, topic, received_at) ⇒ Karafka::Messages::Message
Returns message object with payload and metadata.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/karafka/messages/builders/message.rb', line 14 def call(, topic, received_at) = Karafka::Messages::Metadata.new( timestamp: ., offset: .offset, deserializers: topic.deserializers, partition: .partition, topic: topic.name, received_at: received_at, raw_headers: .headers, raw_key: .key ) # Get the raw payload payload = .payload # And nullify it in the kafka message. This can save a lot of memory when used with # the Pro Cleaner API .instance_variable_set('@payload', nil) # Karafka messages cannot be frozen because of the lazy deserialization feature = Karafka::Messages::Message.new(payload, ) # Assign message to metadata so we can reverse its relationship if needed [:message] = end |