Files
kiri-core/Annotation/Rpc/Consumer.php
T
as2252258@163.com 8137b24865 modify
2021-05-03 03:48:52 +08:00

44 lines
650 B
PHP

<?php
namespace Annotation\Rpc;
use Annotation\Attribute;
use Exception;
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 Exception
*/
public function execute(mixed $class, mixed $method = ''): mixed
{
$rpc = Snowflake::app()->getRpc();
$rpc->addConsumer($this->cmd, [$class, $method]);
return true; // TODO: Change the autogenerated stub
}
}