This commit is contained in:
2021-03-23 15:13:33 +08:00
parent d37926a37d
commit d2db326ecf
2 changed files with 105 additions and 0 deletions
+47
View File
@@ -0,0 +1,47 @@
<?php
namespace Annotation\Rpc;
use Annotation\Attribute;
use ReflectionException;
use Snowflake\Exception\ComponentException;
use Snowflake\Exception\NotFindClassException;
use Snowflake\Snowflake;
/**
* Class Consumer
* @package Annotation\Rpc
*/
#[\Attribute(\Attribute::TARGET_METHOD)] class Consumer extends Attribute
{
/**
* Consumer constructor.
* @param string $cmd
*/
public function __construct(public string $cmd)
{
}
/**
* @param array $handler
* @return mixed
* @throws ReflectionException
* @throws ComponentException
* @throws NotFindClassException
*/
public function execute(array $handler): mixed
{
$rpc = Snowflake::app()->getRpc();
$rpc->addConsumer($this->cmd, $handler);
return parent::execute($handler); // TODO: Change the autogenerated stub
}
}