66 lines
2.2 KiB
PHP
66 lines
2.2 KiB
PHP
<?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;
|
||
}),
|
||
];
|