This commit is contained in:
2021-03-24 11:25:02 +08:00
parent 3279029cc3
commit 5bfe64ac3e
3 changed files with 3 additions and 42 deletions
@@ -15,7 +15,7 @@ use Snowflake\Exception\ConfigException;
use Snowflake\Exception\NotFindClassException; use Snowflake\Exception\NotFindClassException;
use Snowflake\Snowflake; use Snowflake\Snowflake;
#[\Attribute(\Attribute::TARGET_METHOD)] class RpcService extends Attribute #[\Attribute(\Attribute::TARGET_METHOD)] class RpcClient extends Attribute
{ {
private string $uri = ''; private string $uri = '';
-37
View File
@@ -1,37 +0,0 @@
<?php
namespace Annotation\Rpc;
use Annotation\Attribute;
use JetBrains\PhpStorm\Pure;
/**
* Class Producer
* @package Annotation\Rpc
*/
#[\Attribute(\Attribute::TARGET_CLASS)] class Producer extends Attribute
{
/**
* Producer constructor.
* @param string $name
*/
public function __construct(private string $name)
{
}
/**
* @param array $handler
* @return mixed
*/
#[Pure] public function execute(array $handler): mixed
{
return parent::execute($handler); // TODO: Change the autogenerated stub
}
}
@@ -17,7 +17,7 @@ use Snowflake\Snowflake;
* Class RpcClient * Class RpcClient
* @package Annotation\Rpc * @package Annotation\Rpc
*/ */
#[\Attribute(\Attribute::TARGET_CLASS)] class RpcService extends Attribute #[\Attribute(\Attribute::TARGET_CLASS)] class RpcProducer extends Attribute
{ {
private array $config; private array $config;
@@ -26,20 +26,18 @@ use Snowflake\Snowflake;
/** /**
* RpcClient constructor. * RpcClient constructor.
* @param string $cmd * @param string $cmd
* @param string $host
* @param int $port * @param int $port
* @param int $timeout * @param int $timeout
* @param int $mode * @param int $mode
*/ */
public function __construct( public function __construct(
public string $cmd, public string $cmd,
public string $host,
public int $port, public int $port,
public int $timeout = 1, public int $timeout = 1,
public int $mode = SWOOLE_SOCK_TCP6 public int $mode = SWOOLE_SOCK_TCP6
) )
{ {
$this->config = ['host' => $host, 'port' => $port, 'mode' => $mode, 'timeout' => $timeout]; $this->config = ['port' => $port, 'mode' => $mode, 'timeout' => $timeout];
} }