Added event BeforeConsumerCreated into ConsumerManager. (#6897)

This commit is contained in:
李铭昕 2024-06-19 12:12:36 +08:00 committed by GitHub
parent 2b07523528
commit f039856130
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 27 additions and 0 deletions

View File

@ -8,6 +8,7 @@
- [#6876](https://github.com/hyperf/hyperf/pull/6876) Added method `Hyperf\Database\Concerns\Builder::eachById`.
- [#6878](https://github.com/hyperf/hyperf/pull/6878) Added methods `whereMorphRelation` and `orWhereMorphRelation` into `Hyperf\Database\Model\Concerns\QueriesRelationships`.
- [#6883](https://github.com/hyperf/hyperf/pull/6883) Added methods `getIndexes` `hasIndex` and `getIndexListing` into `Hyperf\Database\Schema\Builder`.
- [#6897](https://github.com/hyperf/hyperf/pull/6897) Added event `BeforeConsumerCreated` into ConsumerManager.
## Optimized

View File

@ -21,6 +21,7 @@ use Hyperf\Di\Annotation\AnnotationCollector;
use Hyperf\Kafka\Annotation\Consumer as ConsumerAnnotation;
use Hyperf\Kafka\Event\AfterConsume;
use Hyperf\Kafka\Event\BeforeConsume;
use Hyperf\Kafka\Event\BeforeConsumerCreated;
use Hyperf\Kafka\Event\FailToConsume;
use Hyperf\Kafka\Exception\InvalidConsumeResultException;
use Hyperf\Process\AbstractProcess;
@ -108,6 +109,7 @@ class ConsumerManager
{
$consumerConfig = $this->getConsumerConfig();
$consumer = $this->consumer;
$this->dispatcher?->dispatch(new BeforeConsumerCreated($consumer, $consumerConfig));
$longLangConsumer = new LongLangConsumer(
$consumerConfig,
function (ConsumeMessage $message) use ($consumer, $consumerConfig) {

View File

@ -0,0 +1,24 @@
<?php
declare(strict_types=1);
/**
* This file is part of Hyperf.
*
* @link https://www.hyperf.io
* @document https://hyperf.wiki
* @contact group@hyperf.io
* @license https://github.com/hyperf/hyperf/blob/master/LICENSE
*/
namespace Hyperf\Kafka\Event;
use Hyperf\Kafka\AbstractConsumer;
use longlang\phpkafka\Consumer\ConsumerConfig;
class BeforeConsumerCreated extends Event
{
public function __construct(AbstractConsumer $consumer, public ConsumerConfig $config)
{
parent::__construct($consumer);
}
}