modify
This commit is contained in:
+11
-1
@@ -4,6 +4,9 @@
|
||||
namespace Annotation;
|
||||
|
||||
|
||||
use Kafka\ConsumerInterface;
|
||||
use Kafka\TaskContainer;
|
||||
|
||||
/**
|
||||
* Class Kafka
|
||||
* @package Annotation
|
||||
@@ -16,7 +19,7 @@ namespace Annotation;
|
||||
* Kafka constructor.
|
||||
* @param string $topic
|
||||
*/
|
||||
public function __construct(public string $topic, public string $groupId, public ?string $brokers = null)
|
||||
public function __construct(public string $topic)
|
||||
{
|
||||
|
||||
}
|
||||
@@ -28,6 +31,13 @@ namespace Annotation;
|
||||
*/
|
||||
public function execute(array $handler): mixed
|
||||
{
|
||||
if (!($handler[0] instanceof ConsumerInterface)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$container = TaskContainer::getInstance();
|
||||
$container->addConsumer($this->topic, [$handler[0], 'onHandler']);
|
||||
|
||||
return parent::execute($handler); // TODO: Change the autogenerated stub
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user