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

45 lines
674 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)
{
}
/**
2021-07-12 17:17:36 +08:00
* @param mixed $class
* @param mixed $method
* @return bool
2021-04-01 10:11:20 +08:00
* @throws Exception
2021-03-23 15:13:33 +08:00
*/
2021-07-12 17:17:36 +08:00
public function execute(mixed $class, mixed $method = ''): bool
{
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
}
}