Exemple #1
0
 def _to_message(self, tp: TP, record: Any) -> ConsumerMessage:
     # convert timestamp to seconds from int milliseconds.
     timestamp_type: int
     timestamp: Optional[int]
     timestamp_type, timestamp = record.timestamp()
     timestamp_s: float = cast(float, None)
     if timestamp is not None:
         timestamp_s = timestamp / 1000.0
     key = record.key()
     key_size = len(key) if key is not None else 0
     value = record.value()
     value_size = len(value) if value is not None else 0
     return ConsumerMessage(
         record.topic(),
         record.partition(),
         record.offset(),
         timestamp_s,
         timestamp_type,
         [],  # headers
         key,
         value,
         None,
         key_size,
         value_size,
         tp,
     )
Exemple #2
0
 def _to_message(self, tp: TP, record: Any) -> ConsumerMessage:
     timestamp: Optional[int] = record.timestamp
     timestamp_s: float = cast(float, None)
     if timestamp is not None:
         timestamp_s = timestamp / 1000.0
     return ConsumerMessage(
         record.topic,
         record.partition,
         record.offset,
         timestamp_s,
         record.timestamp_type,
         record.key,
         record.value,
         record.checksum,
         record.serialized_key_size,
         record.serialized_value_size,
         tp,
     )