This commit is contained in:
as2252258@163.com
2021-04-11 17:18:54 +08:00
parent 364c638d81
commit 6fbb0dea76
4 changed files with 245 additions and 134 deletions
+11 -1
View File
@@ -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
}