改名
This commit is contained in:
@@ -6,6 +6,7 @@ namespace Annotation\Rpc;
|
||||
|
||||
use Annotation\Attribute;
|
||||
use ReflectionException;
|
||||
use Rpc\IProducer;
|
||||
use Snowflake\Exception\ComponentException;
|
||||
use Snowflake\Exception\NotFindClassException;
|
||||
use Snowflake\Snowflake;
|
||||
@@ -18,6 +19,8 @@ use Snowflake\Snowflake;
|
||||
#[\Attribute(\Attribute::TARGET_CLASS)] class RpcService extends Attribute
|
||||
{
|
||||
|
||||
private array $config;
|
||||
|
||||
|
||||
/**
|
||||
* RpcClient constructor.
|
||||
@@ -33,6 +36,7 @@ use Snowflake\Snowflake;
|
||||
public int $mode = SWOOLE_SOCK_TCP6
|
||||
)
|
||||
{
|
||||
$this->config = ['host' => $this->host, 'port' => $this->port, 'mode' => $this->mode];
|
||||
}
|
||||
|
||||
|
||||
@@ -45,13 +49,15 @@ use Snowflake\Snowflake;
|
||||
*/
|
||||
public function execute(array $handler): mixed
|
||||
{
|
||||
// TODO: Change the autogenerated stub
|
||||
if ($handler[0] instanceof IProducer) {
|
||||
call_user_func([$handler[0], 'instance']);
|
||||
}
|
||||
|
||||
$rpc = Snowflake::app()->getRpc();
|
||||
$rpc->addProducer($this->cmd, $handler, [
|
||||
'host' => $this->host,
|
||||
'port' => $this->port,
|
||||
'mode' => $this->mode
|
||||
]);
|
||||
return parent::execute($handler); // TODO: Change the autogenerated stub
|
||||
$rpc->addProducer($this->cmd, $handler, $this->config);
|
||||
|
||||
return parent::execute($handler);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user