- @louis-cuny opened merge request.
- Issue was unassigned.
- Status changed to Needs review
about 1 year ago 9:53am 12 October 2023 - π«π·France louis-cuny
I rerolled the patch but removed the non-related to this issue stuff
Please review
Summary
The \Drupal\kafka\Queue\KafkaQueue / \Drupal\kafka\Queue\KafkaItem classes have hard-coded handling for serializing / unserializing the messages sent to, and received from Kafka, preventing other formats like JSON from being sent to Kafka.
For example, the producer code looks like this:
public function createItem($data) {
if (!$this->isExisting || $this->isDeleted) {
throw new \RuntimeException(new TranslatableMarkup(
"Queue @name is not usable at this time.", ['@name' => $this->name]
));
}
$item = new KafkaItem($data, $this->uuid->generate());
$this->producerTopic()->produce(RD_KAFKA_PARTITION_UA, 0, $item->payloadString());
return $item->item_id;
}
public function payloadString() {
// Order the keys for better readability of the serialized format, making
// it usable without the class if needed.
$array = [
'item_id' => $this->item_id,
'created' => $this->created,
'data' => $this->data,
];
return serialize($array);
}
Using PHP's serialize function, without allowing a path for override seriously limits the utility of this module since PHP's serialize function is not a universal standard across other applications that might need to communicate with Drupal.
Expected Results
We should be able to easily override the format of messages produced to Kafka through the Queue interface, without having to override the \Drupal\kafka\Queue\KafkaQueue.
Needs review
1.0
Code
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.
I rerolled the patch but removed the non-related to this issue stuff
Please review