From 620ccca6cf7f1abd98578f21f11ccda4a8fe1917 Mon Sep 17 00:00:00 2001 From: "Alexander (SASh) Alexiev" Date: Fri, 11 Apr 2025 22:42:45 +0300 Subject: [PATCH] upd: use destruct method to flush the consumer instead of permanently binding the class to a callback in terminate --- src/Producers/Producer.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Producers/Producer.php b/src/Producers/Producer.php index 616bd8e8..c17c8d43 100644 --- a/src/Producers/Producer.php +++ b/src/Producers/Producer.php @@ -40,11 +40,12 @@ public function __construct( 'conf' => $this->getConf($this->config->getProducerOptions()), ]); $this->dispatcher = App::make(Dispatcher::class); + } + public function __destruct() + { if ($this->async) { - app()->terminating(function () { - $this->flush(); - }); + $this->flush(); } }