From 76f45f694c51c505913726d2ab484e236d0ef7cf Mon Sep 17 00:00:00 2001 From: Simon Podlipsky Date: Tue, 17 Sep 2024 14:08:33 +0200 Subject: [PATCH] feat: propagate result code on `Producer::flushMessages` err --- src/Clients/Producer/KafkaProducer.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Clients/Producer/KafkaProducer.php b/src/Clients/Producer/KafkaProducer.php index 679e733..64a5c5c 100644 --- a/src/Clients/Producer/KafkaProducer.php +++ b/src/Clients/Producer/KafkaProducer.php @@ -9,6 +9,7 @@ use RdKafka\ProducerTopic; use RuntimeException; +use function assert; use function sprintf; use const RD_KAFKA_PARTITION_UA; @@ -76,8 +77,10 @@ public function flushMessages(int $timeoutMs = 10000): void } } + assert($result !== null); + if ($result !== RD_KAFKA_RESP_ERR_NO_ERROR) { - throw new RuntimeException('Was unable to flush, messages might be lost!'); + throw new RuntimeException('Was unable to flush, messages might be lost!', $result); } } }