Files
kiri-core/Annotation/Rpc/Consumer.php
T

44 lines
650 B
PHP
Raw Normal View History

2021-03-23 15:13:33 +08:00
<?php
namespace Annotation\Rpc;
use Annotation\Attribute;
2021-04-01 10:11:20 +08:00
use Exception;
2021-03-23 15:13:33 +08:00
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
2021-04-01 10:11:20 +08:00
* @throws Exception
2021-03-23 15:13:33 +08:00
*/
2021-05-03 03:48:52 +08:00
public function execute(mixed $class, mixed $method = ''): mixed
2021-03-23 15:13:33 +08:00
{
$rpc = Snowflake::app()->getRpc();
2021-05-03 03:48:52 +08:00
$rpc->addConsumer($this->cmd, [$class, $method]);
return true; // TODO: Change the autogenerated stub
2021-03-23 15:13:33 +08:00
}
}