Skip to content

Commit

Permalink
feat: propagate result code on Producer::flushMessages err
Browse files Browse the repository at this point in the history
  • Loading branch information
simPod committed Sep 17, 2024
1 parent 03b58f1 commit 76f45f6
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);

Check warning on line 83 in src/Clients/Producer/KafkaProducer.php

View check run for this annotation

Codecov / codecov/patch

src/Clients/Producer/KafkaProducer.php#L83

Added line #L83 was not covered by tests
}
}
}

0 comments on commit 76f45f6

Please sign in to comment.