Skip to content

Commit

Permalink
feat: propagate result code on Producer::flushMessages err (#183)
Browse files Browse the repository at this point in the history
  • Loading branch information
simPod authored Sep 17, 2024
1 parent 03b58f1 commit c1e1e3a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Clients/Producer/KafkaProducer.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use RdKafka\ProducerTopic;
use RuntimeException;

use function assert;
use function sprintf;

use const RD_KAFKA_PARTITION_UA;
Expand Down Expand Up @@ -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);
}
}
}

0 comments on commit c1e1e3a

Please sign in to comment.