diff --git a/app/Controller/Test/ProxyController.php b/app/Controller/Test/ProxyController.php index 930fa91..28b22b3 100644 --- a/app/Controller/Test/ProxyController.php +++ b/app/Controller/Test/ProxyController.php @@ -8,6 +8,7 @@ use App\Service\Test\Proxy\AopService; use App\Service\Test\Proxy\BasicSubjectService; use App\Service\Test\Proxy\DynamicProxyService; use App\Service\Test\Proxy\Payment\PaymentService; +use App\Service\Test\Proxy\RemoteService; use App\Service\Test\Proxy\UserInfoService; use App\Service\Test\Proxy\UserService; use Hyperf\HttpServer\Annotation\Controller; @@ -60,8 +61,12 @@ class ProxyController return (new UserService)->handle(); } - public function remote() + /** + * @return array + */ + #[RequestMapping(path: 'remote', methods: 'GET')] + public function remote(): array { - + return (new RemoteService)->handle(); } } diff --git a/app/Interface/Test/Proxy/OrderInterface.php b/app/Interface/Test/Proxy/OrderInterface.php new file mode 100644 index 0000000..52d0791 --- /dev/null +++ b/app/Interface/Test/Proxy/OrderInterface.php @@ -0,0 +1,13 @@ + uniqid(), + 'status' => 'created', + ]; + } +} \ No newline at end of file diff --git a/app/Service/Test/Proxy/Remote/RemoteOrderServiceProxy.php b/app/Service/Test/Proxy/Remote/RemoteOrderServiceProxy.php new file mode 100644 index 0000000..dbc26cf --- /dev/null +++ b/app/Service/Test/Proxy/Remote/RemoteOrderServiceProxy.php @@ -0,0 +1,51 @@ +rpcClient = $rpcClient; +// $this->logger = $logger; +// } + + public function createOrder(array $data): array + { + $data['request_id'] = uniqid(); + $data['timestamp'] = time(); + + $this->logger->log('Sending order creation request'.json_encode($data)); + + try { +// $response = $this->rpcClient->__call('OrderService.createOrder',[$data]); + + $this->logger->log('Order created successfully, response:'.json_encode($response)); + + return $response; + } catch (Throwable $exception) { + $this->logger->error('Order creation error: '.$exception->getMessage()); + return []; + } + } +} \ No newline at end of file diff --git a/app/Service/Test/Proxy/RemoteService.php b/app/Service/Test/Proxy/RemoteService.php new file mode 100644 index 0000000..d3e5248 --- /dev/null +++ b/app/Service/Test/Proxy/RemoteService.php @@ -0,0 +1,35 @@ +localOrderService->createOrder($this->request->all()); + + return $this->return->success(); + } +} \ No newline at end of file diff --git a/composer.json b/composer.json index c3e3311..ae691b4 100644 --- a/composer.json +++ b/composer.json @@ -31,6 +31,7 @@ "hyperf/model-cache": "~3.1.0", "hyperf/process": "~3.1.0", "hyperf/redis": "~3.1.0", + "hyperf/rpc-client": "^3.1", "hyperf/tracer": "~3.1.0" }, "require-dev": { diff --git a/composer.lock b/composer.lock index 8d3cc7a..e598543 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "4ac3b7f3d4fc837bc272d5727a863971", + "content-hash": "03d201d24ea04aa8cfada8967ab9b056", "packages": [ { "name": "carbonphp/carbon-doctrine-types", @@ -2744,6 +2744,71 @@ ], "time": "2025-06-30T01:39:01+00:00" }, + { + "name": "hyperf/load-balancer", + "version": "v3.1.42", + "source": { + "type": "git", + "url": "https://github.com/hyperf/load-balancer.git", + "reference": "13d23eae71f917df4df54f7439076360dc5f9cc0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/hyperf/load-balancer/zipball/13d23eae71f917df4df54f7439076360dc5f9cc0", + "reference": "13d23eae71f917df4df54f7439076360dc5f9cc0", + "shasum": "" + }, + "require": { + "hyperf/coordinator": "~3.1.0", + "hyperf/coroutine": "~3.1.0", + "markrogoyski/math-php": "^2.0", + "php": ">=8.1", + "psr/log": "^1.0 || ^2.0 || ^3.0" + }, + "type": "library", + "extra": { + "hyperf": { + "config": "Hyperf\\LoadBalancer\\ConfigProvider" + }, + "branch-alias": { + "dev-master": "3.1-dev" + } + }, + "autoload": { + "psr-4": { + "Hyperf\\LoadBalancer\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "A load balancer library for Hyperf.", + "homepage": "https://hyperf.io", + "keywords": [ + "hyperf", + "load-balancer", + "php", + "swoole" + ], + "support": { + "docs": "https://hyperf.wiki", + "issues": "https://github.com/hyperf/hyperf/issues", + "pull-request": "https://github.com/hyperf/hyperf/pulls", + "source": "https://github.com/hyperf/hyperf" + }, + "funding": [ + { + "url": "https://hyperf.wiki/#/zh-cn/donate", + "type": "custom" + }, + { + "url": "https://opencollective.com/hyperf", + "type": "open_collective" + } + ], + "time": "2024-09-25T02:54:12+00:00" + }, { "name": "hyperf/logger", "version": "v3.1.57", @@ -3344,6 +3409,149 @@ ], "time": "2025-07-03T04:20:32+00:00" }, + { + "name": "hyperf/rpc", + "version": "v3.1.57", + "source": { + "type": "git", + "url": "https://github.com/hyperf/rpc.git", + "reference": "1c81cd46be8d1926096cf333849add07e755ced3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/hyperf/rpc/zipball/1c81cd46be8d1926096cf333849add07e755ced3", + "reference": "1c81cd46be8d1926096cf333849add07e755ced3", + "shasum": "" + }, + "require": { + "hyperf/codec": "~3.1.0", + "hyperf/collection": "~3.1.0", + "hyperf/context": "~3.1.0", + "hyperf/contract": "~3.1.0", + "hyperf/stringable": "~3.1.0", + "hyperf/support": "~3.1.0", + "jetbrains/phpstorm-attributes": "^1.0", + "php": ">=8.1" + }, + "type": "library", + "extra": { + "hyperf": [], + "branch-alias": { + "dev-master": "3.1-dev" + } + }, + "autoload": { + "psr-4": { + "Hyperf\\Rpc\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "A rpc basic library for Hyperf.", + "homepage": "https://hyperf.io", + "keywords": [ + "hyperf", + "php", + "rpc", + "swoole" + ], + "support": { + "docs": "https://hyperf.wiki", + "issues": "https://github.com/hyperf/hyperf/issues", + "pull-request": "https://github.com/hyperf/hyperf/pulls", + "source": "https://github.com/hyperf/hyperf" + }, + "funding": [ + { + "url": "https://hyperf.wiki/#/zh-cn/donate", + "type": "custom" + }, + { + "url": "https://opencollective.com/hyperf", + "type": "open_collective" + } + ], + "time": "2025-06-06T02:41:30+00:00" + }, + { + "name": "hyperf/rpc-client", + "version": "v3.1.57", + "source": { + "type": "git", + "url": "https://github.com/hyperf/rpc-client.git", + "reference": "ff9299aed4aebd3c6aeb871e3e5482dfa262bb7d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/hyperf/rpc-client/zipball/ff9299aed4aebd3c6aeb871e3e5482dfa262bb7d", + "reference": "ff9299aed4aebd3c6aeb871e3e5482dfa262bb7d", + "shasum": "" + }, + "require": { + "hyperf/code-parser": "~3.1.0", + "hyperf/collection": "~3.1.0", + "hyperf/contract": "~3.1.0", + "hyperf/coroutine": "~3.1.0", + "hyperf/load-balancer": "~3.1.0", + "hyperf/rpc": "~3.1.0", + "hyperf/support": "~3.1.0", + "jetbrains/phpstorm-attributes": "^1.0", + "php": ">=8.1", + "psr/container": "^1.0 || ^2.0" + }, + "suggest": { + "hyperf/di": "For better container experience.", + "hyperf/pool": "Required to use connection pool.", + "hyperf/service-governance": "Required to fetch the nodes info from service governance." + }, + "type": "library", + "extra": { + "hyperf": { + "config": "Hyperf\\RpcClient\\ConfigProvider" + }, + "branch-alias": { + "dev-master": "3.1-dev" + } + }, + "autoload": { + "psr-4": { + "Hyperf\\RpcClient\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "An abstract rpc server component for Hyperf.", + "homepage": "https://hyperf.io", + "keywords": [ + "hyperf", + "json-rpc", + "php", + "rpc", + "rpc-client", + "swoole" + ], + "support": { + "docs": "https://hyperf.wiki", + "issues": "https://github.com/hyperf/hyperf/issues", + "pull-request": "https://github.com/hyperf/hyperf/pulls", + "source": "https://github.com/hyperf/hyperf" + }, + "funding": [ + { + "url": "https://hyperf.wiki/#/zh-cn/donate", + "type": "custom" + }, + { + "url": "https://opencollective.com/hyperf", + "type": "open_collective" + } + ], + "time": "2025-06-06T02:41:30+00:00" + }, { "name": "hyperf/serializer", "version": "v3.1.42", @@ -3886,6 +4094,48 @@ ], "time": "2023-11-03T22:38:29+00:00" }, + { + "name": "jetbrains/phpstorm-attributes", + "version": "1.2", + "source": { + "type": "git", + "url": "https://github.com/JetBrains/phpstorm-attributes.git", + "reference": "64de815a4509c29e00d5e3474087fd24c171afc2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/JetBrains/phpstorm-attributes/zipball/64de815a4509c29e00d5e3474087fd24c171afc2", + "reference": "64de815a4509c29e00d5e3474087fd24c171afc2", + "shasum": "" + }, + "type": "library", + "autoload": { + "psr-4": { + "JetBrains\\PhpStorm\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "JetBrains", + "homepage": "https://www.jetbrains.com" + } + ], + "description": "PhpStorm specific attributes", + "keywords": [ + "attributes", + "jetbrains", + "phpstorm" + ], + "support": { + "issues": "https://youtrack.jetbrains.com/newIssue?project=WI", + "source": "https://github.com/JetBrains/phpstorm-attributes/tree/1.2" + }, + "time": "2024-10-11T10:46:19+00:00" + }, { "name": "laminas/laminas-mime", "version": "2.12.0", @@ -4007,6 +4257,81 @@ ], "time": "2024-10-29T13:46:07+00:00" }, + { + "name": "markrogoyski/math-php", + "version": "v2.11.0", + "source": { + "type": "git", + "url": "https://github.com/markrogoyski/math-php.git", + "reference": "ae499f31513821a62f3d2fb8c6f0d3a333e8b591" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/markrogoyski/math-php/zipball/ae499f31513821a62f3d2fb8c6f0d3a333e8b591", + "reference": "ae499f31513821a62f3d2fb8c6f0d3a333e8b591", + "shasum": "" + }, + "require": { + "ext-json": "*", + "php": ">=7.2.0" + }, + "require-dev": { + "php-coveralls/php-coveralls": "^2.0", + "php-parallel-lint/php-parallel-lint": "^1.2", + "phploc/phploc": "*", + "phpmd/phpmd": "^2.6", + "phpstan/phpstan": "^1.10", + "phpunit/phpunit": "^8.5", + "squizlabs/php_codesniffer": "3.*" + }, + "type": "library", + "autoload": { + "psr-4": { + "MathPHP\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mark Rogoyski", + "email": "mark@rogoyski.com", + "homepage": "https://github.com/markrogoyski", + "role": "Lead developer" + }, + { + "name": "Kevin Nowaczyk", + "homepage": "https://github.com/Beakerboy", + "role": "Developer" + }, + { + "name": "MathPHP Community of Contributors", + "homepage": "https://github.com/markrogoyski/math-php/graphs/contributors" + } + ], + "description": "Math Library for PHP. Features descriptive statistics and regressions; Continuous and discrete probability distributions; Linear algebra with matrices and vectors, Numerical analysis; special mathematical functions; Algebra", + "homepage": "https://github.com/markrogoyski/math-php/", + "keywords": [ + "algebra", + "combinatorics", + "distributions", + "linear algebra", + "math", + "mathematics", + "matrix", + "numerical analysis", + "probability", + "regressions", + "statistics" + ], + "support": { + "issues": "https://github.com/markrogoyski/math-php/issues", + "source": "https://github.com/markrogoyski/math-php/tree/v2.11.0" + }, + "time": "2025-01-26T20:16:06+00:00" + }, { "name": "monolog/monolog", "version": "3.9.0",