From b77a4a53e503e7635065c9a5bf32d295af4de6cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A0=82=E5=90=89=E8=AF=83=E5=BE=B7=E6=8B=89=E6=9B=BC?= =?UTF-8?q?=E6=9F=A5=E7=9A=84=E8=8B=B1=E8=B1=AA?= Date: Thu, 6 Aug 2026 11:17:42 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9EArticleService=E8=81=9A?= =?UTF-8?q?=E5=90=88=E5=A5=91=E7=BA=A6=E4=B8=8E=E6=B6=88=E8=B4=B9=E8=80=85?= =?UTF-8?q?=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- consumers/article_service.php | 40 +++++++++++++ src/ArticleService/ArticleService.php | 86 +++++++++++++++++++++++++++ 2 files changed, 126 insertions(+) create mode 100644 consumers/article_service.php create mode 100644 src/ArticleService/ArticleService.php diff --git a/consumers/article_service.php b/consumers/article_service.php new file mode 100644 index 0000000..89eec7c --- /dev/null +++ b/consumers/article_service.php @@ -0,0 +1,40 @@ + 'ArticleService', + // 服务接口名 + 'service' => ArticleService::class, + // 服务提供者的服务协议,可选,默认值为 jsonrpc-http + 'protocol' => 'jsonrpc-http', + // 负载均衡算法,可选,默认值为 random + 'load_balancer' => 'random', + // 这个消费者要从哪个服务中心获取节点信息,如不配置则不会从服务中心获取节点信息 + 'registry' => [ + 'protocol' => env('CONSUMERS_PROTOCOL', 'consul'), + 'address' => env('CONSUMERS_ADDRESS', 'http://127.0.0.1:8500'), + ], + // 配置项,会影响到 Packer 和 Transporter + 'options' => [ + 'connect_timeout' => 5.0, + 'recv_timeout' => 5.0, + 'settings' => [ + 'open_eof_split' => true, + 'package_eof' => "\r\n", + ], + 'retry_count' => 2, + 'retry_interval' => 100, + 'heartbeat' => 30, + 'pool' => [ + 'min_connections' => 1, + 'max_connections' => 32, + 'connect_timeout' => 10.0, + 'wait_timeout' => 3.0, + 'heartbeat' => -1, + 'max_idle_time' => 60.0, + ], + ], +]; diff --git a/src/ArticleService/ArticleService.php b/src/ArticleService/ArticleService.php new file mode 100644 index 0000000..faea4ad --- /dev/null +++ b/src/ArticleService/ArticleService.php @@ -0,0 +1,86 @@ +