Files
wh-api/config/autoload/services.php
ykxiao 8a3ab17b25
Some checks failed
Build Docker / build (push) Has been cancelled
增加基础配置
2025-07-12 11:59:33 +08:00

66 lines
2.2 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
declare(strict_types=1);
/**
* This file is part of Hyperf.
*
* @link https://www.hyperf.io
* @document https://hyperf.wiki
* @contact group@hyperf.io
* @license https://github.com/hyperf/hyperf/blob/master/LICENSE
*/
use App\JsonRpc\EasyAppServiceInterface;
use App\JsonRpc\InventoryServiceInterface;
use App\JsonRpc\RoleServiceInterface;
use App\JsonRpc\UserAuthServiceInterface;
use function Hyperf\Support\value;
return [
'consumers' => value(function () {
$consumers = [];
$services = [
'UserAuthService' => UserAuthServiceInterface::class,
'EasyAppService' => EasyAppServiceInterface::class,
'InventoryService' => InventoryServiceInterface::class,
'RoleService' => RoleServiceInterface::class,
];
foreach ($services as $name => $interface) {
$consumers[] = [
'name' => $name,
'service' => $interface,
'protocol' => 'jsonrpc-http',
'load_balancer' => 'random',
'registry' => [
'protocol' => 'nacos',
'address' => 'http://127.0.0.1:8848',
],
'options' => [
'connect_timeout' => 5.0,
'recv_timeout' => 5.0,
'settings' => [
// 开启连接池
'open_connection_pool' => true,
],
// 重试次数,默认值为 2收包超时不进行重试。暂只支持 JsonRpcPoolTransporter
'retry_count' => 2,
// 重试间隔,毫秒
'retry_interval' => 100,
// 使用多路复用 RPC 时的心跳间隔null 为不触发心跳
'heartbeat' => 30,
'pool' => [
'min_connections' => 1,
'max_connections' => 100,
'connect_timeout' => 10.0,
'wait_timeout' => 3.0,
'heartbeat' => 30,
'max_idle_time' => 60.0,
],
]
];
}
return $consumers;
}),
];